Ruby Command-Line Arguments
If you’re writing a serious Ruby application (not a Rails application necessarily), this question may apply to you: how do you access command-line arguments in Ruby?
Ruby provides an array called ARGV (all upper-case). This array contains all the command-line arguments; so if you run this:
ruby script.rb first second third
… then ARGV.length is 3, ARGV[0] is “first”, ARGV[1] is second, and ARGV[2] is third.
Tags: command-line, environment, ruby Posted in


May 18th, 2009 at 9:59 am
thx to write this.