Class: Syntax::Action

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#commandsObject (readonly)

Returns the value of attribute commands.



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

def commands
  @commands
end

#http_verbObject (readonly)

Returns the value of attribute http_verb.



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

def http_verb
  @http_verb
end

#nodeObject (readonly)

Returns the value of attribute node.



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

def node
  @node
end

#respondObject (readonly)

Returns the value of attribute respond.



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

def respond
  @respond
end

Instance Method Details

#parse(node) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/silicon/routing/syntax/action.rb', line 5

def parse(node)
  @node = node
  @commands = []

  elements.each do |element|
    if element.is_a? HttpVerb
      @http_verb = element.text_value
    end

    if element.is_a? Commands
      @commands = element.parse
    end

    if element.is_a? Respond
      @respond = element.parse
    end
  end

  self
end

#to_hashObject



26
27
28
# File 'lib/silicon/routing/syntax/action.rb', line 26

def to_hash
  {http_verb: @http_verb, commands: @commands, view: @respond.view, http_status: @respond.http_status}
end