class Hash
Public Instance Methods
argumentize(args_field=nil)
click to toggle source
Turn a hash into arguments.
h = { :list => [1,2], :base => "HI" } h.argumentize #=> [ [], { :list => [1,2], :base => "HI" } ] h.argumentize(:list) #=> [ [1,2], { :base => "HI" } ]
# File lib/ratch/core_ext/to_console.rb, line 83 def argumentize(args_field=nil) config = dup if args_field args = [config.delete(args_field)].flatten.compact else args = [] end args << config return args end
Also aliased as: command_vector
to_argv()
click to toggle source
Convert a Hash
into command line parameters. The array is accepted in the format of Ruby method arguments –ie. [arg1, arg2, …, hash]
# File lib/ratch/core_ext/to_console.rb, line 59 def to_argv flags = [] each do |f,v| m = f.to_s.size == 1 ? '-' : '--' case v when Array v.each{ |e| flags << "#{m}#{f}='#{e}'" } when true flags << "#{m}#{f}" when false, nil # nothing else flags << "#{m}#{f}='#{v}'" end end flags end
to_console()
click to toggle source
Convert a Hash
into command line arguments. The array is accepted in the format of Ruby method arguments –ie. [arg1, arg2, …, hash]
# File lib/ratch/core_ext/to_console.rb, line 52 def to_console to_argv.join(' ') end