Class: Syntax::Route

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nodeObject (readonly)

Returns the value of attribute node.



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

def node
  @node
end

#parameterObject (readonly)

Returns the value of attribute parameter.



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

def parameter
  @parameter
end

#pathObject (readonly)

Returns the value of attribute path.



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

def path
  @path
end

Instance Method Details

#parse(node) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/silicon/routing/syntax/route.rb', line 5

def parse(node)
  @node = node

  elements.each do |element|
    if element.is_a? Parameter
      @parameter = element.text_value
    end

    if element.is_a? Path
      @path = element.text_value
    end
  end

  self
end

#to_hashObject



21
22
23
# File 'lib/silicon/routing/syntax/route.rb', line 21

def to_hash
  {path: @path, parameter: @parameter}
end