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.
Class Method Summary collapse
Instance Method Summary collapse
- #delegate ⇒ Object
- #delegate=(delegate) ⇒ Object
- #failure_reason ⇒ Object
-
#initialize(delegate = nil) ⇒ Parser
constructor
A new instance of Parser.
- #parse(input) ⇒ Object
Constructor Details
#initialize(delegate = nil) ⇒ Parser
Returns a new instance of Parser.
5 6 7 8 |
# File 'lib/harby/parser.rb', line 5 def initialize(delegate = nil) @parser = Grammar::ArgumentsParser.new @parser.delegate = delegate || NullDelegate.new 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 |
Class Method Details
.parse(input, delegate = nil) ⇒ Object
27 28 29 |
# File 'lib/harby/parser.rb', line 27 def self.parse(input, delegate = nil) new(delegate).parse(input) end |
Instance Method Details
#delegate ⇒ Object
19 20 21 |
# File 'lib/harby/parser.rb', line 19 def delegate @parser.delegate end |
#delegate=(delegate) ⇒ Object
15 16 17 |
# File 'lib/harby/parser.rb', line 15 def delegate=(delegate) @parser.delegate = delegate end |
#failure_reason ⇒ Object
23 24 25 |
# File 'lib/harby/parser.rb', line 23 def failure_reason @parser.failure_reason end |
#parse(input) ⇒ Object
10 11 12 13 |
# File 'lib/harby/parser.rb', line 10 def parse(input) result = @parser.parse(input) result ? result.parsed_args : nil end |