Class: Temple::Mixins::GrammarDSL::Element Private
- Defined in:
- lib/temple/mixins/grammar_dsl.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
- #after_copy(source) ⇒ Object private
-
#initialize(grammar, rule) ⇒ Element
constructor
private
A new instance of Element.
- #match(exp, unmatched) ⇒ Object private
Methods inherited from Or
Methods inherited from Rule
Constructor Details
#initialize(grammar, rule) ⇒ Element
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Element.
86 87 88 89 |
# File 'lib/temple/mixins/grammar_dsl.rb', line 86 def initialize(grammar, rule) super(grammar) @rule = grammar.Rule(rule) end |
Instance Method Details
#after_copy(source) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
97 98 99 100 101 102 |
# File 'lib/temple/mixins/grammar_dsl.rb', line 97 def after_copy(source) @children = @children.map do |child| child == source ? self : child.copy_to(@grammar) end @rule = @rule.copy_to(@grammar) end |
#match(exp, unmatched) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
91 92 93 94 95 |
# File 'lib/temple/mixins/grammar_dsl.rb', line 91 def match(exp, unmatched) return false unless Array === exp && !exp.empty? head, *tail = exp @rule.match(head, unmatched) && super(tail, unmatched) end |