Example of an interactive program developed by ruby: ruby Development

Source: Internet
Author: User
Tags wxwidgets

Example of an interactive program developed by ruby: ruby Development

Implement the interaction function in a terminal similar to pry, ronin, and msf. ripl gem is mainly used here:

1. Call defined methods, such as help
2. Be able to execute system commands
3. ruby parsing similar to irb/pry

Installation:

gem install riplgem install ripl-shell_commands

Example

Ripl, a gem, also provides many plug-ins. The following is a simple terminal interaction implementation:

require 'ripl'
require 'ripl / shell_commands'
require 'ripl / color_result'
require 'ripl / color_streams'
require 'ripl / commands'
require 'ripl / rocket'

#Set output color
Ripl.config [: color_streams_stdout] =: light_blue
Ripl.config [: color_streams_stderr] =: light_red

#Definition prompt symbol
Ripl.config [: prompt] = lambda {"[# {Ripl.shell.line.to_s}] cmd>"}

# Define plugins, load files, etc ...

class Dodolook
  def help
  puts "xiaomi noops blog"
  end
  def name
  "wilbur"
  end
end
dodo = Dodolook.new

verison = "1.0.3"
Ripl.start: binding => dodo.instance_eval {binding} 

Use

After running the program on the terminal, a prompt such as [0] cmd> is displayed. The variables/methods such as help, name, and dodo can be completed by tab.

Run the shell command and add !, Example :! Df
There are more internal methods, such as history, list, jump...


Can ruby write desktop software?

Ruby's mature GUI binding libraries include FXRuby, Ruby-GNOME2, RubyCocoa, and wxRuby.

FXRuby
WxRuby is an open-source ruby interface development kit. It provides Ruby support for the cross-platform C ++ interface framework, wxWidgets. WxWidgets is a mature interface development kit with many features. It uses local controls to provide local interface styles for Linux, Windows, and OS X. WxRuby aims to provide dynamic Ruby extensions, with prototype development and common interface development.

Ruby-GNOME2
The Ruby-GNOME2 provides Ruby Bindings for the GNOME 2.0 development environment and is currently active in updates. If you like GTK interface, you will love Ruby-GNOME2. GTK currently provides runtime libraries for multiple platforms, such as Linux and Windows. That is to say, applications developed using GTK can run on multiple platforms. Unlike other Interface Development kits, Ruby-GNOME2 not only provides interface controls, it provides the entire GNOME 2.0 Environment, including Ruby/GLib2, Ruby/ATK, Ruby/Pango, Ruby/GTK2, and so on.

RubyCocoa
RubyCocoa is a Mac OS X interface development kit. You can use object-oriented Ruby for Cocoa development. You can use Ruby to create and use Cocoa objects. You can use Ruby and Objective-C to compile Cocoa software at the same time. If you like Ruby and Mac, and your software is only intended to run on Mac, RubyCocoa is your best choice. Xcode 3.0 has already included RubyCocoa by default to support Ruby to develop Mac applications.

WxRuby
WxRuby is an open-source ruby interface development kit. It provides Ruby support for the cross-platform C ++ interface framework, wxWidgets. WxWidgets is a mature interface development kit with many features. It uses local controls to provide local interface styles for Linux, Windows, and OS X. WxRuby aims to provide dynamic Ruby extensions, with prototype development and common interface development.

WxRuby is an open-source ruby interface development kit. It provides Ruby support for the cross-platform C ++ interface framework, wxWidgets. WxWidgets is a mature interface development kit with many features. It uses local controls to provide local interface styles for Linux, Windows, and OS X. WxRuby aims to provide dynamic Ruby extensions, with prototype development and common interface development.
WxRuby2 is the current development version. It uses SWIG to generate encapsulation code. WxRuby2 provides almost all the controls and functions of wxWidgets 2.6.3. Currently, only the preview version is released, which is suitable for personal purposes and prototype development.

What programs are used by Ruby to compile web pages or develop large software like C ++?

Ruby is a powerful object-oriented scripting language that allows you to easily and quickly perform object-oriented programming. sometimes using formal object-oriented languages like Smalltalk, Eiffel, or C ++ to develop small projects seems a little complicated, and Ruby can meet these object-oriented programming needs. of course, you can also use Ruby for general process-oriented programming. ruby has a strong text processing capability, which is different from Perl. at the same time, Ruby's syntax is simple, and Exception Handling and iterator structures make programming simple and clear. in short, you can perform object-oriented development as quickly and easily as using Perl.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.