class DarkskyWeather::Api::WeatherData

Attributes

latitude[R]
longitude[R]
offset[R]
raw[R]
sources[R]
timestamp[R]
timezone[R]

Public Class Methods

new(timestamp, source_url, raw) click to toggle source
# File lib/darksky_weather/api/weather_data.rb, line 8
def initialize(timestamp, source_url, raw)
  @timestamp  = timestamp
  @source_url = source_url
  @raw        = raw

  @latitude  = raw['latitude']
  @longitude = raw['longitude']
  @offset    = raw['offset']
  @timezone  = raw['timezone']
  @sources   = raw['flags']['sources']
end

Public Instance Methods

currently() click to toggle source
# File lib/darksky_weather/api/weather_data.rb, line 20
def currently
  return nil unless @raw['currently']
  return OpenStruct.new(@raw['currently'].deep_transform_keys{|k| k.underscore })
end
daily() click to toggle source
# File lib/darksky_weather/api/weather_data.rb, line 25
def daily
  return nil unless @raw['daily']
  @raw['daily']['data'].map do |hsh|
    OpenStruct.new(hsh.deep_transform_keys{|k| k.underscore })
  end
end
hourly() click to toggle source
# File lib/darksky_weather/api/weather_data.rb, line 32
def hourly
  return nil unless @raw['hourly']
  @raw['hourly']['data'].map do |hsh|
    OpenStruct.new(hsh.deep_transform_keys{|k| k.underscore })
  end
end
minutely() click to toggle source
# File lib/darksky_weather/api/weather_data.rb, line 39
def minutely
  return nil unless @raw['minutely']
  @raw['minutely']['data'].map do |hsh|
    OpenStruct.new(hsh.deep_transform_keys{|k| k.underscore })
  end
end