class Weathercom::Location

Attributes

client[R]
lat[R]
lng[R]

Public Class Methods

new(lat, lng, client) click to toggle source
# File lib/weathercom/location.rb, line 4
def initialize(lat, lng, client)
  @lat, @lng, @client = lat, lng, client
end

Public Instance Methods

current_observation() click to toggle source
# 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()
Alias for: daily_forecasts_10
daily_forecasts_10() click to toggle source
# 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
Also aliased as: daily_forecasts
daily_forecasts_5() click to toggle source
# 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()
hourly_forecasts_240() click to toggle source
# 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
Also aliased as: hourly_forecasts
wwir_forecast() click to toggle source

When Will It Rain Forecast

# 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

Private Instance Methods

query() click to toggle source
# File lib/weathercom/location.rb, line 54
def query
  "units=e"
end
url_prefix() click to toggle source
# File lib/weathercom/location.rb, line 50
def url_prefix
  "/v1/geocode/#{URI.encode(lat.to_s)}/#{URI.encode(lng.to_s)}"
end