module Citrus::Proxy
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.
Attributes
rule_name[R]
The name of this proxy's rule.
Public Class Methods
new(rule_name='')
click to toggle source
# File lib/citrus.rb, line 758 def initialize(rule_name='<proxy>') self.rule_name = rule_name end
Public Instance Methods
exec(input, events=[])
click to toggle source
Returns an array of events for this rule on the given input
.
# File lib/citrus.rb, line 776 def exec(input, events=[]) index = events.size if input.exec(rule, events).size > index # Proxy objects insert themselves into the event stream in place of the # rule they are proxy for. events[index] = self end events end
rule()
click to toggle source
Returns the underlying Rule for this proxy.
# File lib/citrus.rb, line 771 def rule @rule ||= resolve! end
rule_name=(rule_name)
click to toggle source
Sets the name of the rule this rule is proxy for.
# File lib/citrus.rb, line 763 def rule_name=(rule_name) @rule_name = rule_name.to_sym end