Object
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/syckle/core_ext.rb, line 123 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
Convert a Hash into command line parameters. The array is accepted in the format of Ruby method arguments –ie. [arg1, arg2, …, hash]
# File lib/syckle/core_ext.rb, line 101 def to_argv flags = map do |f,v| m = f.to_s.size == 1 ? '-' : '--' case v when Array v.collect{ |e| "#{m}#{f}='#{e}'" }.join(' ') when true "#{m}#{f}" when false, nil '' else "#{m}#{f}='#{v}'" end end end
Convert a Hash into command line arguments. The array is accepted in the format of Ruby method arguments –ie. [arg1, arg2, …, hash]
# File lib/syckle/core_ext.rb, line 94 def to_console to_argv.join(' ') end
Generated with the Darkfish Rdoc Generator 2.