Class: Weathercom::Location

Inherits:
Object
  • Object
show all
Defined in:
lib/weathercom/location.rb

Direct Known Subclasses

GeocodedLocation

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#clientObject (readonly)

Returns the value of attribute client.



10
11
12
# File 'lib/weathercom/location.rb', line 10

def client
  @client
end

#latObject (readonly)

Returns the value of attribute lat.



8
9
10
# File 'lib/weathercom/location.rb', line 8

def lat
  @lat
end

#lngObject (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_observationObject



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'], .new(payload['metadata']))
end

#daily_forecasts_10Object 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, .new(payload['metadata']))
  end
end

#daily_forecasts_5Object



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, .new(payload['metadata']))
  end
end

#hourly_forecasts_240Object 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, .new(payload['metadata']))
  end
end

#wwir_forecastObject

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'], .new(payload['metadata']))
end