Class: Harby::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/harby/parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#parserObject (readonly)

Returns the value of attribute parser.



3
4
5
# File 'lib/harby/parser.rb', line 3

def parser
  @parser
end

Instance Method Details

#delegateObject



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_reasonObject



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