Class: Scribble::Parsing::Nester

Inherits:
Object
  • Object
show all
Defined in:
lib/scribble/parsing/nester.rb

Instance Method Summary collapse

Constructor Details

#initialize(nodes) ⇒ Nester

Returns a new instance of Nester.


4
5
6
# File 'lib/scribble/parsing/nester.rb', line 4

def initialize nodes
  @nodes = nodes
end

Instance Method Details

#nodes(root = true) ⇒ Object


8
9
10
11
12
13
14
15
16
17
18
# File 'lib/scribble/parsing/nester.rb', line 8

def nodes root = true
  [].tap do |nodes|
    while step(root)
      nodes << node
      if node.block?
        @current = node
        node.nodes = nodes false
      end
    end
  end
end