Class: Musa::GenerativeGrammar::Implementation::RepeatNode 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 repetition of a node.
Generates options with different repetition counts. Created by Node#repeat.
Instance Method Summary collapse
- #_options(parent: nil, depth: nil, &condition) ⇒ Object private
- #initialize(node, max = nil) ⇒ void constructor private
Constructor Details
#initialize(node, max = nil) ⇒ void
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.
641 642 643 644 645 646 |
# File 'lib/musa-dsl/generative/generative-grammar.rb', line 641 def initialize(node, max = nil) @node = node @max = max super() end |
Instance Method Details
#_options(parent: nil, depth: 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.
649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 |
# File 'lib/musa-dsl/generative/generative-grammar.rb', line 649 def (parent: nil, depth: nil, &condition) parent ||= [] depth ||= 0 r = [] if @max.nil? || depth < @max = @node.(parent: parent, &condition) .each do |node_option| r << node_option = (parent: parent + node_option, depth: depth + 1, &condition) .each do |node_suboption| r << node_option + node_suboption end end end r end |