Class: DarkSky::Location::Day

Inherits:
CommonMethods show all
Defined in:
lib/darksky-api/day.rb

Instance Method Summary collapse

Methods inherited from CommonMethods

#apparent_temperature, #clear?, #cloud_cover, #cloudy?, #dew_point, #foggy?, #humidity, #icon, #ozone, #precip_intensity, #precip_intensity_text, #precip_probability, #precip_type, #pressure, #rainy?, #sleet?, #snowy?, #summary, #uv_index, #visibility, #wind_bearing, #wind_bearing_text, #wind_gust, #wind_speed, #windy?

Constructor Details

#initialize(location, days_from_current) ⇒ Day

automatically called by Location

Parameters:

  • location (Location)

    where to get data from

Since:

  • 0.1.3



7
8
9
10
# File 'lib/darksky-api/day.rb', line 7

def initialize(location, days_from_current)
  @location = location
  @days_from_current = days_from_current
end

Instance Method Details

#apparent_temperature_highNumeric Also known as: high_apparent_temperature, apparent_high_temperature, high_feels_like, feels_like_high, high_heat_index, heat_index_high, high_wind_chill, wind_chill_high

Returns high feels like on day.

Examples:

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

Returns:

  • (Numeric)

    high feels like on day

Since:

  • 0.1.3



142
143
144
# File 'lib/darksky-api/day.rb', line 142

def apparent_temperature_high
  data[:apparentTemperatureHigh]
end

#apparent_temperature_high_timeTime Also known as: high_apparent_temperature_time, apparent_high_temperature_time, high_feels_like_time, feels_like_high_time, high_heat_index_time, heat_index_high_time, high_wind_chill_time, wind_chill_high_time

Returns time of high apparent temperature.

Examples:

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

Returns:

  • (Time)

    time of high apparent temperature

Since:

  • 0.1.3



176
177
178
# File 'lib/darksky-api/day.rb', line 176

def apparent_temperature_high_time
  Time.at data[:apparentTemperatureHighTime]
end

#apparent_temperature_lowNumeric Also known as: low_apparent_temperature, apparent_low_temperature, low_feels_like, feels_like_low, low_heat_index, heat_index_low, low_wind_chill, wind_chill_low

Returns low feels like on day.

Examples:

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

Returns:

  • (Numeric)

    low feels like on day

Since:

  • 0.1.3



159
160
161
# File 'lib/darksky-api/day.rb', line 159

def apparent_temperature_low
  data[:apparentTemperatureLow]
end

#apparent_temperature_low_timeTime Also known as: low_apparent_temperature_time, apparent_low_temperature_time, low_feels_like_time, feels_like_low_time, low_heat_index_time, heat_index_low_time, low_wind_chill_time, wind_chill_low_time

Returns time of low apparent temperature.

Examples:

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

Returns:

  • (Time)

    time of low apparent temperature

Since:

  • 0.1.3



193
194
195
# File 'lib/darksky-api/day.rb', line 193

def apparent_temperature_low_time
  Time.at data[:apparentTemperatureLowTime]
end

#dateDate

Returns object for the day.

Examples:

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

Returns:

  • (Date)

    object for the day

Since:

  • 0.1.3



17
18
19
20
# 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

#moon_phaseNumeric

Returns phase of the moon (0 to 1).

Examples:

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

Returns:

  • (Numeric)

    phase of the moon (0 to 1)

Since:

  • 0.1.3



87
88
89
# File 'lib/darksky-api/day.rb', line 87

def moon_phase
  data[:moonPhase]
end

#moon_phase_textString

Returns textual representation of moon phase.

Examples:

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

Returns:

  • (String)

    textual representation of moon phase

Since:

  • 0.1.3



96
97
98
99
# 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_accumulationNumeric

Returns precipitation accumulation on day.

Examples:

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

Returns:

  • (Numeric)

    precipitation accumulation on day

Since:

  • 0.1.3



133
134
135
# File 'lib/darksky-api/day.rb', line 133

def precip_accumulation
  data[:precipAccumulation]
end

#precip_intensity_maxNumeric

Returns maximum precipitation intensity on day.

Examples:

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

Returns:

  • (Numeric)

    maximum precipitation intensity on day

Since:

  • 0.1.3



106
107
108
# File 'lib/darksky-api/day.rb', line 106

def precip_intensity_max
  data[:precipIntensityMax]
end

#precip_intensity_max_textString

Returns text representation of maximum precipitation intensity on day.

Examples:

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

Returns:

  • (String)

    text representation of maximum precipitation intensity on day

Since:

  • 0.1.3



115
116
117
# File 'lib/darksky-api/day.rb', line 115

def precip_intensity_max_text
  _precip_intensity_text(precip_intensity_max)
end

#precip_intensity_max_timeTime

Returns time of maximum precipitation intensity.

Examples:

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

Returns:

  • (Time)

    time of maximum precipitation intensity

Since:

  • 0.1.3



124
125
126
# File 'lib/darksky-api/day.rb', line 124

def precip_intensity_max_time
  Time.at data[:precipIntensityMaxTime] if data[:precipIntensityMaxTime]
end

#sunrise_timeTime Also known as: sunrise

Returns object with sunrise timestamp.

Examples:

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

Returns:

  • (Time)

    object with sunrise timestamp

Since:

  • 0.1.3



67
68
69
# File 'lib/darksky-api/day.rb', line 67

def sunrise_time
  Time.at data[:sunriseTime]
end

#sunset_timeTime Also known as: sunset

Returns object with sunset timestamp.

Examples:

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

Returns:

  • (Time)

    object with sunset timestamp

Since:

  • 0.1.3



77
78
79
# File 'lib/darksky-api/day.rb', line 77

def sunset_time
  Time.at data[:sunsetTime]
end

#temperature_highNumeric Also known as: high_temperature

Returns high temperature for the day.

Examples:

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

Returns:

  • (Numeric)

    high temperature for the day

Since:

  • 0.1.3



27
28
29
# File 'lib/darksky-api/day.rb', line 27

def temperature_high
  data[:temperatureHigh]
end

#temperature_high_timeTime Also known as: high_temperature_time

Returns time of high temperature.

Examples:

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

Returns:

  • (Time)

    time of high temperature

Since:

  • 0.1.3



37
38
39
# File 'lib/darksky-api/day.rb', line 37

def temperature_high_time
  Time.at data[:temperatureHighTime]
end

#temperature_lowNumeric Also known as: low_temperature

Returns low temperature for the day.

Examples:

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

Returns:

  • (Numeric)

    low temperature for the day

Since:

  • 0.1.3



47
48
49
# File 'lib/darksky-api/day.rb', line 47

def temperature_low
  data[:temperatureLow]
end

#temperature_low_timeTime Also known as: low_temperature_time

Returns time of low temperature.

Examples:

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

Returns:

  • (Time)

    time of low temperature

Since:

  • 0.1.3



57
58
59
# File 'lib/darksky-api/day.rb', line 57

def temperature_low_time
  Time.at data[:temperatureLowTime]
end

#uv_index_timeTime

Returns max UV index time on day.

Examples:

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

Returns:

  • (Time)

    max UV index time on day

Since:

  • 0.1.3



219
220
221
# File 'lib/darksky-api/day.rb', line 219

def uv_index_time
  Time.at data[:uvIndexTime]
end

#wind_gust_timeTime

Returns wind gust time on day.

Examples:

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

Returns:

  • (Time)

    wind gust time on day

Since:

  • 0.1.3



210
211
212
# File 'lib/darksky-api/day.rb', line 210

def wind_gust_time
  Time.at data[:windGustTime]
end