Class: Syntax::Node

Inherits:
Treetop::Runtime::SyntaxNode
  • Object
show all
Defined in:
lib/silicon/routing/syntax/node.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#actionsObject

Returns the value of attribute actions.



3
4
5
# File 'lib/silicon/routing/syntax/node.rb', line 3

def actions
  @actions
end

#after_commandsObject

Returns the value of attribute after_commands.



3
4
5
# File 'lib/silicon/routing/syntax/node.rb', line 3

def after_commands
  @after_commands
end

#before_commandsObject

Returns the value of attribute before_commands.



3
4
5
# File 'lib/silicon/routing/syntax/node.rb', line 3

def before_commands
  @before_commands
end

#levelObject

Returns the value of attribute level.



3
4
5
# File 'lib/silicon/routing/syntax/node.rb', line 3

def level
  @level
end

#my_nodesObject

Returns the value of attribute my_nodes.



3
4
5
# File 'lib/silicon/routing/syntax/node.rb', line 3

def my_nodes
  @my_nodes
end

#parent_nodeObject

Returns the value of attribute parent_node.



3
4
5
# File 'lib/silicon/routing/syntax/node.rb', line 3

def parent_node
  @parent_node
end

#routeObject

Returns the value of attribute route.



3
4
5
# File 'lib/silicon/routing/syntax/node.rb', line 3

def route
  @route
end

Instance Method Details

#parse(parent_node = nil) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/silicon/routing/syntax/node.rb', line 5

def parse(parent_node = nil)
  @parent_node = parent_node

  elements.each do |element|
    if element.is_a? Indent
      @level = element.elements.length
    end

    if element.is_a? Route
      @route = element.parse(self)
    end

    if element.is_a? Actions
      @actions = element.parse(self)
    end

    if element.is_a? Nodes
      @my_nodes = element.parse(self)
    end

    if element.is_a? BeforeSection
      @before_commands = element.parse.commands
    end

    if element.is_a? AfterSection
      @after_commands = element.parse.commands
    end
  end

  self
end

#to_hashObject



37
38
39
40
41
42
43
44
45
# File 'lib/silicon/routing/syntax/node.rb', line 37

def to_hash
  {
    route: @route.to_hash,
    actions: @actions,
    level: @level,
    before: @before_commands,
    after: @after_commands
  }
end