Sha256: 8c2365fd4e409e12fa830b541d737401fb75dd3b4998d0af500547406fbdd524
Contents?: true
Size: 772 Bytes
Versions: 1
Compression:
Stored size: 772 Bytes
Contents
require 'raph/parser/assignment_parser' module Raph module Parser # 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=' # class AssignmentParser < BaseParser def parse(args) assgs = [] args.each do |a| assgs << a if assignment? a end assgs end def assignment?(option) option.include?('=')\ && !option.start_with?('=')\ && !option.end_with?('=') end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
raph-0.0.1 | lib/raph/parser/assignment_parser.rb |