Class: Musa::GenerativeGrammar::Implementation::OrNode
- Defined in:
- lib/musa-dsl/generative/generative-grammar.rb
Instance Method Summary collapse
- #_options(parent: nil, &condition) ⇒ Object
-
#initialize(node1, node2) ⇒ OrNode
constructor
A new instance of OrNode.
Methods inherited from Node
#[], #limit, #next, #options, #or, #repeat, #size, #to_serie
Constructor Details
#initialize(node1, node2) ⇒ OrNode
Returns a new instance of OrNode.
211 212 213 214 215 |
# File 'lib/musa-dsl/generative/generative-grammar.rb', line 211 def initialize(node1, node2) @node1 = node1 @node2 = node2 super() end |
Instance Method Details
#_options(parent: nil, &condition) ⇒ Object
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 |
# File 'lib/musa-dsl/generative/generative-grammar.rb', line 217 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 |