class Raph::Parser::AssignmentParser
Considers option as assignment if and only if it has an assignment character (=) between option key and option value.
Assumes that each option doesn’t have spaces.
Example of assignments:
'h=one' '-assg=two' '--config=my-file'
Example of non-assignments:
'-h' '-h=' 'h=' '=' '--config='
Public Instance Methods
assignment?(option)
click to toggle source
# File lib/raph/parser/assignment_parser.rb, line 31 def assignment?(option) option.count('=') == 1 && !option.start_with?('=') && !option.end_with?('=') end
parse(args)
click to toggle source
# File lib/raph/parser/assignment_parser.rb, line 18 def parse(args) assgs = {} args.each do |a| if assignment? a kv = a.split('=') k = to_underscored_sym(kv.first) v = kv.last assgs[k] = v end end assgs end