A Proxy is a Rule that is a placeholder for another rule. It stores the name of some other rule in the grammar internally and resolves it to the actual Rule object at runtime. This lazy evaluation permits creation of Proxy objects for rules that may not yet be defined.
Included modules
Attributes
rule_name | [R] | The name of this proxy’s rule. |
Public class methods
new
(rule_name='<proxy>')
[show source]
# File lib/citrus.rb, line 759 759: def initialize(rule_name='<proxy>') 760: self.rule_name = rule_name 761: end
Public instance methods
exec
(input, events=[])
Returns an array of events for this rule on the given input.
[show source]
# File lib/citrus.rb, line 777 777: def exec(input, events=[]) 778: index = events.size 779: 780: if input.exec(rule, events).size > index 781: # Proxy objects insert themselves into the event stream in place of the 782: # rule they are proxy for. 783: events[index] = self 784: end 785: 786: events 787: end
rule
()
Returns the underlying Rule for this proxy.
[show source]
# File lib/citrus.rb, line 772 772: def rule 773: @rule ||= resolve! 774: end
rule_name=
(rule_name)
Sets the name of the rule this rule is proxy for.
[show source]
# File lib/citrus.rb, line 764 764: def rule_name=(rule_name) 765: @rule_name = rule_name.to_sym 766: end