Class: Musa::GenerativeGrammar::Implementation::OrNode Private
- Defined in:
- lib/musa-dsl/generative/generative-grammar.rb
Overview
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.
Node representing alternation between two nodes.
Generates options from either node1 or node2.
Created by Node#or or | operator.
Instance Method Summary collapse
- #_options(parent: nil, &condition) ⇒ Object private
-
#initialize(node1, node2) ⇒ OrNode
constructor
private
A new instance of OrNode.
Constructor Details
#initialize(node1, node2) ⇒ OrNode
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 OrNode.
549 550 551 552 553 |
# File 'lib/musa-dsl/generative/generative-grammar.rb', line 549 def initialize(node1, node2) @node1 = node1 @node2 = node2 super() end |
Instance Method Details
#_options(parent: nil, &condition) ⇒ 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.
556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 |
# File 'lib/musa-dsl/generative/generative-grammar.rb', line 556 def (parent: nil, &condition) parent ||= [] r = [] @node1.(parent: parent, &condition).each do |node_option| r << node_option if !block_given? || yield(parent + node_option) end @node2.(parent: parent, &condition).each do |node_option| r << node_option if !block_given? || yield(parent + node_option) end r end |