Parent

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/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
Also aliased as: command_vector
command_vector(args_field=nil) click to toggle source
Alias for: argumentize
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/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
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/syckle/core_ext.rb, line 94
def to_console
  to_argv.join(' ')
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.