Class: Tumblargh::Node::Block

Inherits:
Root
  • Object
show all
Defined in:
lib/tumblargh/node/block.rb

Instance Method Summary collapse

Methods inherited from Root

#to_s

Methods inherited from Base

#to_s, #type

Instance Method Details

#nameObject



5
6
7
8
# File 'lib/tumblargh/node/block.rb', line 5

def name
  # First node is BlockStart
  elements.first.name
end

#optionsObject



10
11
12
# File 'lib/tumblargh/node/block.rb', line 10

def options
  elements.first.options
end

#to_treeObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/tumblargh/node/block.rb', line 14

def to_tree
  ary = [type, name, options]

  # Second node is a Treetop SyntaxNode which holds
  # the rest of the block contents. Extra parse node
  # due to grouping in the block grammar
  elements[1].elements.each do |e|
    if e.respond_to?(:to_tree)
      ary << e.to_tree
    else
      raise ParserError, "Unknown node type '#{e.class.name}' in Block '#{name}'"
    end
  end

  ary
end