Class: Harby::Parser
- Inherits:
-
Object
- Object
- Harby::Parser
- Defined in:
- lib/harby/parser.rb
Instance Attribute Summary collapse
-
#parser ⇒ Object
readonly
Returns the value of attribute parser.
Instance Method Summary collapse
- #delegate ⇒ Object
- #delegate=(delegate) ⇒ Object
- #failure_reason ⇒ Object
-
#initialize(delegate = nil, &block) ⇒ Parser
constructor
A new instance of Parser.
- #parse(input) ⇒ Object
Constructor Details
#initialize(delegate = nil, &block) ⇒ Parser
Returns a new instance of Parser.
5 6 7 8 |
# File 'lib/harby/parser.rb', line 5 def initialize(delegate = nil, &block) @parser = Grammar::ArgumentsParser.new @parser.delegate = delegate || block end |
Instance Attribute Details
#parser ⇒ Object (readonly)
Returns the value of attribute parser.
3 4 5 |
# File 'lib/harby/parser.rb', line 3 def parser @parser end |
Instance Method Details
#delegate ⇒ Object
14 15 16 |
# File 'lib/harby/parser.rb', line 14 def delegate @parser.delegate end |
#delegate=(delegate) ⇒ Object
10 11 12 |
# File 'lib/harby/parser.rb', line 10 def delegate=(delegate) @parser.delegate = delegate end |
#failure_reason ⇒ Object
18 19 20 |
# File 'lib/harby/parser.rb', line 18 def failure_reason @parser.failure_reason end |
#parse(input) ⇒ Object
22 23 24 25 |
# File 'lib/harby/parser.rb', line 22 def parse(input) result = @parser.parse(input) result ? result.parsed_args : nil end |