ARGV Parser
See exemples for more informations :
// Go : http://blackh.badfile.net/wordz/
Function :
1 2 def options(param) 3 4 i = 0 5 ARGV.each { |valeur| 6 7 if (valeur == '-' + param.to_s) 8 return ARGV[i+1] 9 elseif (valeur != '-' + param.to_s) 10 return false 11 end 12 i += 1 13 } 14 15 end
Usage :
// cmd> ruby test.rb -o foo
1 2 3 out = self.options('o') 4 5 if (out != false and out.empty? == false) 6 puts out # print -> foo 7 end