Class: Weathercom::Location
- Inherits:
-
Object
- Object
- Weathercom::Location
- Defined in:
- lib/weathercom/location.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#lat ⇒ Object
readonly
Returns the value of attribute lat.
-
#lng ⇒ Object
readonly
Returns the value of attribute lng.
Instance Method Summary collapse
- #current_observation ⇒ Object
- #daily_forecasts_10 ⇒ Object (also: #daily_forecasts)
- #daily_forecasts_5 ⇒ Object
- #hourly_forecasts_240 ⇒ Object (also: #hourly_forecasts)
-
#initialize(lat, lng, client) ⇒ Location
constructor
A new instance of Location.
-
#wwir_forecast ⇒ Object
When Will It Rain Forecast.
Constructor Details
#initialize(lat, lng, client) ⇒ Location
Returns a new instance of Location.
4 5 6 |
# File 'lib/weathercom/location.rb', line 4 def initialize(lat, lng, client) @lat, @lng, @client = lat, lng, client end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
10 11 12 |
# File 'lib/weathercom/location.rb', line 10 def client @client end |
#lat ⇒ Object (readonly)
Returns the value of attribute lat.
8 9 10 |
# File 'lib/weathercom/location.rb', line 8 def lat @lat end |
#lng ⇒ Object (readonly)
Returns the value of attribute lng.
9 10 11 |
# File 'lib/weathercom/location.rb', line 9 def lng @lng end |
Instance Method Details
#current_observation ⇒ Object
12 13 14 15 |
# File 'lib/weathercom/location.rb', line 12 def current_observation payload = client.get_json_with_cache("#{url_prefix}/observations/current.json") Observation.new(payload['observation'], Metadata.new(payload['metadata'])) end |
#daily_forecasts_10 ⇒ Object Also known as: daily_forecasts
24 25 26 27 28 29 |
# File 'lib/weathercom/location.rb', line 24 def daily_forecasts_10 payload = client.get_json_with_cache("#{url_prefix}/forecast/daily/10day.json?#{query}") payload['forecasts'].map do |info| DailyForecast.new(info, Metadata.new(payload['metadata'])) end end |
#daily_forecasts_5 ⇒ Object
17 18 19 20 21 22 |
# File 'lib/weathercom/location.rb', line 17 def daily_forecasts_5 payload = client.get_json_with_cache("#{url_prefix}/forecast/daily/5day.json?#{query}") payload['forecasts'].map do |info| DailyForecast.new(info, Metadata.new(payload['metadata'])) end end |
#hourly_forecasts_240 ⇒ Object Also known as: hourly_forecasts
33 34 35 36 37 38 |
# File 'lib/weathercom/location.rb', line 33 def hourly_forecasts_240 payload = client.get_json_with_cache("#{url_prefix}/forecast/hourly/240hour.json?#{query}") payload['forecasts'].map do |info| HourlyForecast.new(info, Metadata.new(payload['metadata'])) end end |
#wwir_forecast ⇒ Object
When Will It Rain Forecast
43 44 45 46 |
# File 'lib/weathercom/location.rb', line 43 def wwir_forecast payload = client.get_json_with_cache("#{url_prefix}/forecast/wwir.json?#{query}") WwirForecast.new(payload['forecast'], Metadata.new(payload['metadata'])) end |