Class: Duststorm::WeatherApi::Base
- Inherits:
-
Object
- Object
- Duststorm::WeatherApi::Base
- Includes:
- Utils::ResponseMapper
- Defined in:
- lib/duststorm/weather_apis/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#lat ⇒ Object
readonly
Returns the value of attribute lat.
-
#lng ⇒ Object
readonly
Returns the value of attribute lng.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #conn ⇒ Object
- #execute ⇒ Object
- #forecast_url ⇒ Object
-
#initialize(lat, lng, options = {}) ⇒ Base
constructor
A new instance of Base.
- #response ⇒ Object
Methods included from Utils::ResponseMapper
#high_temperature_key, #low_temperature_key, #mapped_response_body, #precipitation_key, #summary_key, #sunrise_key, #sunset_key, #temperature_key, #time_key, #wind_speed_key
Constructor Details
#initialize(lat, lng, options = {}) ⇒ Base
Returns a new instance of Base.
8 9 10 11 12 |
# File 'lib/duststorm/weather_apis/base.rb', line 8 def initialize(lat, lng, ={}) @lat = lat @lng = lng @options = end |
Instance Attribute Details
#lat ⇒ Object (readonly)
Returns the value of attribute lat.
6 7 8 |
# File 'lib/duststorm/weather_apis/base.rb', line 6 def lat @lat end |
#lng ⇒ Object (readonly)
Returns the value of attribute lng.
6 7 8 |
# File 'lib/duststorm/weather_apis/base.rb', line 6 def lng @lng end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/duststorm/weather_apis/base.rb', line 6 def @options end |
Instance Method Details
#conn ⇒ Object
24 25 26 |
# File 'lib/duststorm/weather_apis/base.rb', line 24 def conn Faraday.new end |
#execute ⇒ Object
14 15 16 17 18 |
# File 'lib/duststorm/weather_apis/base.rb', line 14 def execute if response.success? mapped_response_body end end |
#forecast_url ⇒ Object
28 29 30 |
# File 'lib/duststorm/weather_apis/base.rb', line 28 def forecast_url root_url + forecast_path end |
#response ⇒ Object
20 21 22 |
# File 'lib/duststorm/weather_apis/base.rb', line 20 def response @response ||= conn.get(forecast_url, ) end |