Class: Weather

Inherits:
Jarvis::Service show all
Defined in:
lib/jarvis/services/weather.rb

Instance Attribute Summary collapse

Attributes inherited from Jarvis::Service

#message, #response

Instance Method Summary collapse

Methods inherited from Jarvis::Service

environment, #initialize, interpreter_pattern, invoke_with, #method_missing, phrases, #validate_environment

Constructor Details

This class inherits a constructor from Jarvis::Service

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Jarvis::Service

Instance Attribute Details

#locationObject

Returns the value of attribute location.



7
8
9
# File 'lib/jarvis/services/weather.rb', line 7

def location
  @location
end

#parsed_responseObject

Returns the value of attribute parsed_response.



7
8
9
# File 'lib/jarvis/services/weather.rb', line 7

def parsed_response
  @parsed_response
end

#temperatureObject

Returns the value of attribute temperature.



7
8
9
# File 'lib/jarvis/services/weather.rb', line 7

def temperature
  @temperature
end

#zip_api_responseObject

Returns the value of attribute zip_api_response.



7
8
9
# File 'lib/jarvis/services/weather.rb', line 7

def zip_api_response
  @zip_api_response
end

Instance Method Details

#runObject



9
10
11
12
13
# File 'lib/jarvis/services/weather.rb', line 9

def run
  self.response = Jarvis.get("http://api.openweathermap.org/data/2.5/weather?q=#{encoded_location}").response
  calculate_temperature
  self.response = "#{weather_description}. The temperature is currently #{temperature}"
end