Class: Musa::GenerativeGrammar::Implementation::ConditionNode

Inherits:
Node
  • Object
show all
Defined in:
lib/musa-dsl/generative/generative-grammar.rb

Instance Method Summary collapse

Methods inherited from Node

#[], #limit, #next, #options, #or, #repeat, #size, #to_serie

Constructor Details

#initialize(node, &block) ⇒ ConditionNode

Returns a new instance of ConditionNode.



192
193
194
195
# File 'lib/musa-dsl/generative/generative-grammar.rb', line 192

def initialize(node, &block)
  @node = node
  @block = block
end

Instance Method Details

#_options(parent: nil, &condition) ⇒ Object



197
198
199
200
201
202
203
204
205
206
207
# File 'lib/musa-dsl/generative/generative-grammar.rb', line 197

def _options(parent: nil, &condition)
  parent ||= []

  r = []

  @node._options(parent: parent, &condition).each do |node_option|
    r << node_option if (!block_given? || yield(parent + node_option)) && @block.call(parent + node_option)
  end

  r
end