Module: FMS::CmdLine::ParamsParser

Defined in:
lib/fms/cmdline.rb

Class Method Summary collapse

Class Method Details

.parse(argv) ⇒ Object



52
53
54
55
56
57
58
59
60
# File 'lib/fms/cmdline.rb', line 52

def parse(argv)
  params = {}
  argv.each do |rawparam|
    param = parse_rawparam rawparam
    params.update(param) if param
  end
  return nil if params.length != argv.length
  params
end

.parse_rawparam(raw) ⇒ Object



62
63
64
65
# File 'lib/fms/cmdline.rb', line 62

def parse_rawparam(raw)
  m = /--(.*)=(.*)/.match(raw)
  {m[1].to_sym => m[2]} if m
end