Class: Musa::GenerativeGrammar::Implementation::RepeatNode
- Defined in:
- lib/musa-dsl/generative/generative-grammar.rb
Instance Method Summary collapse
- #_options(parent: nil, depth: nil, &condition) ⇒ Object
-
#initialize(node, max = nil) ⇒ RepeatNode
constructor
A new instance of RepeatNode.
Methods inherited from Node
#[], #limit, #next, #options, #or, #repeat, #size, #to_serie
Constructor Details
#initialize(node, max = nil) ⇒ RepeatNode
Returns a new instance of RepeatNode.
255 256 257 258 259 260 |
# File 'lib/musa-dsl/generative/generative-grammar.rb', line 255 def initialize(node, max = nil) @node = node @max = max super() end |
Instance Method Details
#_options(parent: nil, depth: nil, &condition) ⇒ Object
262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 |
# File 'lib/musa-dsl/generative/generative-grammar.rb', line 262 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 |