Class: Kangaru::ArgumentParser
- Inherits:
-
Object
- Object
- Kangaru::ArgumentParser
- Defined in:
- lib/kangaru/argument_parser.rb
Instance Attribute Summary collapse
-
#tokens ⇒ Object
readonly
Returns the value of attribute tokens.
Instance Method Summary collapse
-
#initialize(*tokens) ⇒ ArgumentParser
constructor
A new instance of ArgumentParser.
- #parse ⇒ Object
Constructor Details
#initialize(*tokens) ⇒ ArgumentParser
Returns a new instance of ArgumentParser.
7 8 9 |
# File 'lib/kangaru/argument_parser.rb', line 7 def initialize(*tokens) @tokens = tokens end |
Instance Attribute Details
#tokens ⇒ Object (readonly)
Returns the value of attribute tokens.
5 6 7 |
# File 'lib/kangaru/argument_parser.rb', line 5 def tokens @tokens end |
Instance Method Details
#parse ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/kangaru/argument_parser.rb', line 11 def parse grouped_argument_tokens.to_h do |tokens| key = parse_key(tokens.shift || raise) value = parse_value(tokens) [key, value] end end |