Class: Whiskey::Server::Interpretor

Inherits:
Object
  • Object
show all
Defined in:
lib/whiskey/server/interpretor.rb

Instance Method Summary collapse

Constructor Details

#initialize(input) ⇒ Interpretor

Returns a new instance of Interpretor.



4
5
6
7
8
9
10
11
# File 'lib/whiskey/server/interpretor.rb', line 4

def initialize(input)
  @instruction = input
  @response = if has_resource? && has_verb?
    Router.new(instruction.resource, instruction.verb, instruction.parameters)
  else
    Error.new(:not_found)
  end
end

Instance Method Details

#instructionObject



17
18
19
# File 'lib/whiskey/server/interpretor.rb', line 17

def instruction
  OpenStruct.new(@instruction)
end

#responseObject



13
14
15
# File 'lib/whiskey/server/interpretor.rb', line 13

def response
  @response.to_hash
end