class Syntax::Node

Attributes

actions[RW]
after_commands[RW]
before_commands[RW]
level[RW]
my_nodes[RW]
parent_node[RW]
route[RW]

Public Instance Methods

parse(parent_node = nil) click to toggle source
# File lib/dandy/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_hash() click to toggle source
# File lib/dandy/routing/syntax/node.rb, line 37
def to_hash
  {
    route: @route.to_hash,
    actions: @actions,
    level: @level,
    before: @before_commands,
    after: @after_commands
  }
end