class DarkSky::Location::Day

Public Class Methods

new(location, days_from_current) click to toggle source

automatically called by `Location` @since 0.1.3 @param [Location] location where to get data from

# File lib/darksky-api/day.rb, line 7
def initialize(location, days_from_current)
  @location = location
  @days_from_current = days_from_current
end

Public Instance Methods

apparent_high_temperature()
apparent_high_temperature_time()
apparent_low_temperature()
apparent_low_temperature_time()
apparent_temperature_high() click to toggle source

@example

location = DarkSky::Location.new [45, -90]
location.today.apparent_temperature_high #=> high feels like on day

@since 0.1.3 @return [Numeric] high feels like on day

# File lib/darksky-api/day.rb, line 142
def apparent_temperature_high
  data[:apparentTemperatureHigh]
end
apparent_temperature_high_time() click to toggle source

@example

location = DarkSky::Location.new [45, -90]
location.today.apparent_temperature_high_time #=> time of high apparent temperature

@since 0.1.3 @return [Time] time of high apparent temperature

# File lib/darksky-api/day.rb, line 176
def apparent_temperature_high_time
  Time.at data[:apparentTemperatureHighTime]
end
apparent_temperature_low() click to toggle source

@example

location = DarkSky::Location.new [45, -90]
location.today.apparent_temperature_low #=> low feels like on day

@since 0.1.3 @return [Numeric] low feels like on day

# File lib/darksky-api/day.rb, line 159
def apparent_temperature_low
  data[:apparentTemperatureLow]
end
apparent_temperature_low_time() click to toggle source

@example

location = DarkSky::Location.new [45, -90]
location.today.apparent_temperature_low_time #=> time of low apparent temperature

@since 0.1.3 @return [Time] time of low apparent temperature

# File lib/darksky-api/day.rb, line 193
def apparent_temperature_low_time
  Time.at data[:apparentTemperatureLowTime]
end
date() click to toggle source

@example

location = DarkSky::Location.new [45, -90]
location.today.date #=> object for the date

@since 0.1.3 @return [Date] object for the day

# File lib/darksky-api/day.rb, line 17
def date
  # we only want the date, so don't use `Time.at()`
  Date.strptime data[:time].to_s, '%s'
end
feels_like_high()
feels_like_high_time()
feels_like_low()
feels_like_low_time()
heat_index_high()
heat_index_high_time()
heat_index_low()
heat_index_low_time()
high_apparent_temperature()
high_apparent_temperature_time()
high_feels_like()
high_feels_like_time()
high_heat_index()
high_heat_index_time()
high_temperature()
Alias for: temperature_high
high_temperature_time()
high_wind_chill()
high_wind_chill_time()
low_apparent_temperature()
low_apparent_temperature_time()
low_feels_like()
low_feels_like_time()
low_heat_index()
low_heat_index_time()
low_temperature()
Alias for: temperature_low
low_temperature_time()
low_wind_chill()
low_wind_chill_time()
moon_phase() click to toggle source

@example

location = DarkSky::Location.new [45, -90]
location.today.moon_phase #=> moon phase on day

@since 0.1.3 @return [Numeric] phase of the moon (0 to 1)

# File lib/darksky-api/day.rb, line 87
def moon_phase
  data[:moonPhase]
end
moon_phase_text() click to toggle source

@example

location = DarkSky::Location.new [45, -90]
location.today.moon_phase_text #=> textual representation of moon phase

@since 0.1.3 @return [String] textual representation of moon phase

# File lib/darksky-api/day.rb, line 96
def moon_phase_text
  # separate method for easy unit testing
  _moon_phase_text(moon_phase)
end
precip_accumulation() click to toggle source

@example

location = DarkSky::Location.new [45, -90]
location.today.precip_accumulation #=> precipitation accumulation on day

@since 0.1.3 @return [Numeric] precipitation accumulation on day

# File lib/darksky-api/day.rb, line 133
def precip_accumulation
  data[:precipAccumulation]
end
precip_intensity_max() click to toggle source

@example

location = DarkSky::Location.new [45, -90]
location.today.precip_intensity_max #=> precipitation intensity on day

@since 0.1.3 @return [Numeric] maximum precipitation intensity on day

# File lib/darksky-api/day.rb, line 106
def precip_intensity_max
  data[:precipIntensityMax]
end
precip_intensity_max_text() click to toggle source

@example

location = DarkSky::Locaiton.new [45, -90]
location.today.precip_intensity_max_text #=> text representation of maximum precipitation intensity on day

@since 0.1.3 @return [String] text representation of maximum precipitation intensity on day

# File lib/darksky-api/day.rb, line 115
def precip_intensity_max_text
  _precip_intensity_text(precip_intensity_max)
end
precip_intensity_max_time() click to toggle source

@example

location = DarkSky::Location.new [45, -90]
location.today.precip_intensity_max_time #=> object of max time

@since 0.1.3 @return [Time] time of maximum precipitation intensity

# File lib/darksky-api/day.rb, line 124
def precip_intensity_max_time
  Time.at data[:precipIntensityMaxTime] if data[:precipIntensityMaxTime]
end
sunrise()
Alias for: sunrise_time
sunrise_time() click to toggle source

@example

location = DarkSky::Location.new [45, -90]
location.today.sunrise_time #=> sunrise time on day

@since 0.1.3 @return [Time] object with sunrise timestamp

# File lib/darksky-api/day.rb, line 67
def sunrise_time
  Time.at data[:sunriseTime]
end
Also aliased as: sunrise
sunset()
Alias for: sunset_time
sunset_time() click to toggle source

@example

location = DarkSky::Location.new [45, -90]
location.today.sunset_time #=> sunset time on day

@since 0.1.3 @return [Time] object with sunset timestamp

# File lib/darksky-api/day.rb, line 77
def sunset_time
  Time.at data[:sunsetTime]
end
Also aliased as: sunset
temperature_high() click to toggle source

@example

location = DarkSky::Location.new [45, -90]
location.today.temperature_high #=> high temperature for the day

@since 0.1.3 @return [Numeric] high temperature for the day

# File lib/darksky-api/day.rb, line 27
def temperature_high
  data[:temperatureHigh]
end
Also aliased as: high_temperature
temperature_high_time() click to toggle source

@example

location = DarkSky::Location.new [45, -90]
location.today.temperature_high_time #=> time of high temperature

@since 0.1.3 @return [Time] time of high temperature

# File lib/darksky-api/day.rb, line 37
def temperature_high_time
  Time.at data[:temperatureHighTime]
end
Also aliased as: high_temperature_time
temperature_low() click to toggle source

@example

location = DarkSky::Location.new [45, -90]
location.today.temperature_low #=> low temperature for the day

@since 0.1.3 @return [Numeric] low temperature for the day

# File lib/darksky-api/day.rb, line 47
def temperature_low
  data[:temperatureLow]
end
Also aliased as: low_temperature
temperature_low_time() click to toggle source

@example

location = DarkSky::Location.new [45, -90]
location.today.temperature_low_time #=> time of low temperature

@since 0.1.3 @return [Time] time of low temperature

# File lib/darksky-api/day.rb, line 57
def temperature_low_time
  Time.at data[:temperatureLowTime]
end
Also aliased as: low_temperature_time
uv_index_time() click to toggle source

@example

location = DarkSky::Location.new [45, -90]
location.today.uv_index_time #=> max UV index time on day

@since 0.1.3 @return [Time] max UV index time on day

# File lib/darksky-api/day.rb, line 219
def uv_index_time
  Time.at data[:uvIndexTime]
end
wind_chill_high()
wind_chill_high_time()
wind_chill_low()
wind_chill_low_time()
wind_gust_time() click to toggle source

@example

location = DarkSky::Location.new [45, -90]
location.today.wind_gust_time #=> wind gust time on day

@since 0.1.3 @return [Time] wind gust time on day

# File lib/darksky-api/day.rb, line 210
def wind_gust_time
  Time.at data[:windGustTime]
end

Private Instance Methods

_moon_phase_text(phase) click to toggle source

convert numerical moon phase to text 10% around each phase (new, first quarter, full, last quarter) keep this a separate method for testing purposes @since 0.1.3 @return [String] text representation of moon phase

# File lib/darksky-api/day.rb, line 237
def _moon_phase_text(phase)
  if phase < 0.05
    'new moon'
  elsif phase < 0.20
    'waxing crescent moon'
  elsif phase < 0.30
    'first quarter moon'
  elsif phase < 0.45
    'waxing gibbous moon'
  elsif phase < 0.55
    'full moon'
  elsif phase < 0.70
    'waning gibbous moon'
  elsif phase < 0.80
    'last quarter moon'
  elsif phase < 0.95
    'waning crescent moon'
  else
    'new moon'
  end
end
data() click to toggle source

helper to avoid typing this many times over @since 0.1.3 @return [Hash] full data for the given day

# File lib/darksky-api/day.rb, line 228
def data
  @location.full_data[:daily][:data][@days_from_current]
end