Class: DarkSky::CommonMethods
- Inherits:
-
Object
- Object
- DarkSky::CommonMethods
- Defined in:
- lib/darksky-api/common-methods.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#apparent_temperature ⇒ Numeric
(also: #wind_chill, #heat_index, #feels_like)
Current apparent temperature at location.
-
#clear? ⇒ Boolean
If icon is 'clear' variant.
-
#cloud_cover ⇒ Numeric
Current cloud cover at location.
-
#cloudy? ⇒ Boolean
If icon is 'cloudy' or variant.
-
#dew_point ⇒ Numeric
Current dew point at location.
-
#foggy? ⇒ Boolean
If icon is 'fog'.
-
#humidity ⇒ Numeric
Current humidity at location.
-
#icon ⇒ String
Icon representation of current weather at location.
-
#initialize ⇒ CommonMethods
constructor
abstract class, should not be instantiated.
-
#ozone ⇒ Numeric
Current ozone level at location.
-
#precip_intensity ⇒ Numeric
Current precipitation intensity at location.
-
#precip_intensity_text ⇒ String
Text representation of precipitation intensity at location.
-
#precip_probability ⇒ Numeric
Current precipitation probability at location.
-
#precip_type ⇒ String | nil
Current precipitation type at location.
-
#pressure ⇒ Numeric
Current barometric pressure at location.
-
#rainy? ⇒ Boolean
If icon is 'rain'.
-
#sleet? ⇒ Boolean
If icon is 'sleet'.
-
#snowy? ⇒ Boolean
If icon is 'snow'.
-
#summary ⇒ String
Summary of weather at location.
-
#uv_index ⇒ Numeric
Current UV index at location.
-
#visibility ⇒ Numeric
Current visibility at location.
-
#wind_bearing ⇒ Numeric
Current wind bearing at location.
-
#wind_bearing_text ⇒ String
Text representation of bearing.
-
#wind_gust ⇒ Numeric
Current wind gust at location.
-
#wind_speed ⇒ Numeric
Current wind speed at location.
-
#windy? ⇒ Boolean
If icon is 'wind'.
Constructor Details
#initialize ⇒ CommonMethods
abstract class, should not be instantiated
5 6 7 8 |
# File 'lib/darksky-api/common-methods.rb', line 5 def initialize raise NotImplementedError, 'This is an abstract class, and should be be instantiated' end |
Instance Method Details
#apparent_temperature ⇒ Numeric Also known as: wind_chill, heat_index, feels_like
Returns current apparent temperature at location.
15 16 17 |
# File 'lib/darksky-api/common-methods.rb', line 15 def apparent_temperature data[:apparentTemperature] end |
#clear? ⇒ Boolean
Returns if icon is 'clear' variant.
180 181 182 |
# File 'lib/darksky-api/common-methods.rb', line 180 def clear? %w[clear-day clear-night].include? icon end |
#cloud_cover ⇒ Numeric
Returns current cloud cover at location.
27 28 29 |
# File 'lib/darksky-api/common-methods.rb', line 27 def cloud_cover data[:cloudCover] end |
#cloudy? ⇒ Boolean
Returns if icon is 'cloudy' or variant.
234 235 236 |
# File 'lib/darksky-api/common-methods.rb', line 234 def cloudy? %w[cloudy partly-cloudy-day partly-cloudy-night].include? icon end |
#dew_point ⇒ Numeric
Returns current dew point at location.
36 37 38 |
# File 'lib/darksky-api/common-methods.rb', line 36 def dew_point data[:dewPoint] end |
#foggy? ⇒ Boolean
Returns if icon is 'fog'.
225 226 227 |
# File 'lib/darksky-api/common-methods.rb', line 225 def foggy? icon == 'fog' end |
#humidity ⇒ Numeric
Returns current humidity at location.
45 46 47 |
# File 'lib/darksky-api/common-methods.rb', line 45 def humidity data[:humidity] end |
#icon ⇒ String
Returns icon representation of current weather at location.
54 55 56 |
# File 'lib/darksky-api/common-methods.rb', line 54 def icon data[:icon] end |
#ozone ⇒ Numeric
Returns current ozone level at location.
63 64 65 |
# File 'lib/darksky-api/common-methods.rb', line 63 def ozone data[:ozone] end |
#precip_intensity ⇒ Numeric
Returns current precipitation intensity at location.
72 73 74 |
# File 'lib/darksky-api/common-methods.rb', line 72 def precip_intensity data[:precipIntensity] end |
#precip_intensity_text ⇒ String
Returns text representation of precipitation intensity at location.
81 82 83 |
# File 'lib/darksky-api/common-methods.rb', line 81 def precip_intensity_text _precip_intensity_text(precip_intensity) end |
#precip_probability ⇒ Numeric
Returns current precipitation probability at location.
90 91 92 |
# File 'lib/darksky-api/common-methods.rb', line 90 def precip_probability data[:precipProbability] end |
#precip_type ⇒ String | nil
Returns current precipitation type at location.
99 100 101 |
# File 'lib/darksky-api/common-methods.rb', line 99 def precip_type data[:precipType] end |
#pressure ⇒ Numeric
Returns current barometric pressure at location.
108 109 110 |
# File 'lib/darksky-api/common-methods.rb', line 108 def pressure data[:pressure] end |
#rainy? ⇒ Boolean
Returns if icon is 'rain'.
189 190 191 |
# File 'lib/darksky-api/common-methods.rb', line 189 def rainy? icon == 'rain' end |
#sleet? ⇒ Boolean
Returns if icon is 'sleet'.
207 208 209 |
# File 'lib/darksky-api/common-methods.rb', line 207 def sleet? icon == 'sleet' end |
#snowy? ⇒ Boolean
Returns if icon is 'snow'.
198 199 200 |
# File 'lib/darksky-api/common-methods.rb', line 198 def snowy? icon == 'snow' end |
#summary ⇒ String
Returns summary of weather at location.
117 118 119 |
# File 'lib/darksky-api/common-methods.rb', line 117 def summary data[:summary] end |
#uv_index ⇒ Numeric
Returns current UV index at location.
126 127 128 |
# File 'lib/darksky-api/common-methods.rb', line 126 def uv_index data[:uvIndex] end |
#visibility ⇒ Numeric
Returns current visibility at location.
135 136 137 |
# File 'lib/darksky-api/common-methods.rb', line 135 def visibility data[:visibility] end |
#wind_bearing ⇒ Numeric
Returns current wind bearing at location.
144 145 146 |
# File 'lib/darksky-api/common-methods.rb', line 144 def wind_bearing data[:windBearing] end |
#wind_bearing_text ⇒ String
Returns text representation of bearing.
153 154 155 |
# File 'lib/darksky-api/common-methods.rb', line 153 def wind_bearing_text _bearing_text(wind_bearing) end |
#wind_gust ⇒ Numeric
Returns current wind gust at location.
162 163 164 |
# File 'lib/darksky-api/common-methods.rb', line 162 def wind_gust data[:windGust] end |
#wind_speed ⇒ Numeric
Returns current wind speed at location.
171 172 173 |
# File 'lib/darksky-api/common-methods.rb', line 171 def wind_speed data[:windSpeed] end |
#windy? ⇒ Boolean
Returns if icon is 'wind'.
216 217 218 |
# File 'lib/darksky-api/common-methods.rb', line 216 def windy? icon == 'wind' end |