Class: GhostWheel::Parser
- Inherits:
-
Object
- Object
- GhostWheel::Parser
show all
- Extended by:
- Forwardable
- Defined in:
- lib/ghost_wheel/parser.rb
Instance Method Summary
collapse
Constructor Details
#initialize ⇒ Parser
Returns a new instance of Parser.
10
11
12
13
|
# File 'lib/ghost_wheel/parser.rb', line 10
def initialize
@rules = Hash.new
@parsers = Set.new
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &block) ⇒ Object
31
32
33
34
35
36
37
38
39
|
# File 'lib/ghost_wheel/parser.rb', line 31
def method_missing(meth, *args, &block)
if name = named_parse?(meth)
wrap_and_parse(name, *args)
elsif parse? meth
wrap_and_parse(@parsers.to_a.first, *args)
else
super
end
end
|
Instance Method Details
#build_parser(name) ⇒ Object
17
18
19
|
# File 'lib/ghost_wheel/parser.rb', line 17
def build_parser(name)
@parsers << name if @rules.include? name
end
|
#respond_to?(meth) ⇒ Boolean
21
22
23
24
25
26
27
28
29
|
# File 'lib/ghost_wheel/parser.rb', line 21
def respond_to?(meth)
if named_parse? meth
true
elsif parse? meth
true
else
super
end
end
|