RubyWin Tutorial(3)

[Prev] [Index]

Eval Buffer with ARGV

RubyWin can run script with argument(ARGV). Input Ruby1 MDI child window:

ARGV.each do |name|
  print "Hello " + name + "\n"
end

Select [Ruby]-[Eval Buffer with ARGV] menu item. Input ARGV dialog:

Taro Hanako

ARGV dialog

and click [OK] button. RubyWin displays

Hello Taro
Hello Hanako

on Console child window.

Here is a sample script. This script prints out file which you input on ARGV dialog.

ARGV.each do |fname|
  puts "\n----- " + fname + "-----\n"
  File.foreach(fname) do |line|
    puts line
  end
end

Input file name in ARGV dialog, for example 'README INSTALL'.


IRB

RubyWin can run script interactively.

Select [Ruby]-[IRB...] menu item.

Input on IRB chile window:

print "Hello World\n"

Then RubyWin displays

Hello World
nil

Input on IRB chile window:

str = "Hello World"
str.sub("Hello", "Good Morning")

IRB window

When you want to exit IRB window, type 'exit'.

Now, enjoy Ruby programming !!!


[Prev] [Index] Sorry for my poor English.