Class: Temple::Mixins::GrammarDSL::Or 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
- #<<(rule) ⇒ Object (also: #|) private
- #after_copy(source) ⇒ Object private
-
#initialize(grammar, *children) ⇒ Or
constructor
private
A new instance of Or.
- #match(exp, unmatched) ⇒ Object private
Methods inherited from Rule
Constructor Details
#initialize(grammar, *children) ⇒ Or
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 Or.
29 30 31 32 |
# File 'lib/temple/mixins/grammar_dsl.rb', line 29 def initialize(grammar, *children) super(grammar) @children = children.map {|rule| @grammar.Rule(rule) } end |
Instance Method Details
#<<(rule) ⇒ Object Also known as: |
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.
34 35 36 37 |
# File 'lib/temple/mixins/grammar_dsl.rb', line 34 def <<(rule) @children << @grammar.Rule(rule) self end |
#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.
46 47 48 |
# File 'lib/temple/mixins/grammar_dsl.rb', line 46 def after_copy(source) @children = @children.map {|child| child.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.
41 42 43 44 |
# File 'lib/temple/mixins/grammar_dsl.rb', line 41 def match(exp, unmatched) tmp = [] @children.any? {|rule| rule.match(exp, tmp) } || (unmatched.concat(tmp) && false) end |