Class: DarkSky::CommonMethods

Inherits:
Object
  • Object
show all
Defined in:
lib/darksky-api/common-methods.rb

Direct Known Subclasses

Location::Current, Location::Day

Instance Method Summary collapse

Constructor Details

#initializeCommonMethods

abstract class, should not be instantiated

Raises:

  • NotImplementedError



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_temperatureNumeric Also known as: wind_chill, heat_index, feels_like

Returns current apparent temperature at location.

Examples:

location = DarkSky::Location.new [45, -90]
location.current.apparent_temperature #=> apparent temperature at location

Returns:

  • (Numeric)

    current apparent temperature at location

Since:

  • 0.1.4



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.

Examples:

location = DarkSky::Location.new [45, -90]
location.current.clear?

Returns:

  • (Boolean)

    if icon is 'clear' variant

Since:

  • 0.1.4



180
181
182
# File 'lib/darksky-api/common-methods.rb', line 180

def clear?
  %w[clear-day clear-night].include? icon
end

#cloud_coverNumeric

Returns current cloud cover at location.

Examples:

location = DarkSky::Location.new [45, -90]
location.current.cloud_cover #=> cloud cover at location

Returns:

  • (Numeric)

    current cloud cover at location

Since:

  • 0.1.4



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.

Examples:

location = DarkSky::Location.new [45, -90]
location.current.cloudy?

Returns:

  • (Boolean)

    if icon is 'cloudy' or variant

Since:

  • 0.1.4



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_pointNumeric

Returns current dew point at location.

Examples:

location = DarkSky::Location.new [45, -90]
location.current.dew_point #=> dew point at location

Returns:

  • (Numeric)

    current dew point at location

Since:

  • 0.1.4



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'.

Examples:

location = DarkSky::Location.new [45, -90]
location.current.foggy?

Returns:

  • (Boolean)

    if icon is 'fog'

Since:

  • 0.1.4



225
226
227
# File 'lib/darksky-api/common-methods.rb', line 225

def foggy?
  icon == 'fog'
end

#humidityNumeric

Returns current humidity at location.

Examples:

location = DarkSky::Location.new [45, -90]
location.current.humidity #=> humidity at location

Returns:

  • (Numeric)

    current humidity at location

Since:

  • 0.1.4



45
46
47
# File 'lib/darksky-api/common-methods.rb', line 45

def humidity
  data[:humidity]
end

#iconString

Returns icon representation of current weather at location.

Examples:

location = DarkSky::Location.new [45, -90]
location.current.icon #=> icon representation

Returns:

  • (String)

    icon representation of current weather at location

Since:

  • 0.1.4



54
55
56
# File 'lib/darksky-api/common-methods.rb', line 54

def icon
  data[:icon]
end

#ozoneNumeric

Returns current ozone level at location.

Examples:

location = DarkSky::Location.new [45, -90]
location.current.ozone #=> ozone level at location

Returns:

  • (Numeric)

    current ozone level at location

Since:

  • 0.1.4



63
64
65
# File 'lib/darksky-api/common-methods.rb', line 63

def ozone
  data[:ozone]
end

#precip_intensityNumeric

Returns current precipitation intensity at location.

Examples:

location = DarkSky::Location.new [45, -90]
location.current.precip_intensity #=> precipitation intensity at location

Returns:

  • (Numeric)

    current precipitation intensity at location

Since:

  • 0.1.4



72
73
74
# File 'lib/darksky-api/common-methods.rb', line 72

def precip_intensity
  data[:precipIntensity]
end

#precip_intensity_textString

Returns text representation of precipitation intensity at location.

Examples:

location = DarkSky::Locaiton.new [45, -90]
location.current.precip_intensity_text #=> text representation of precipitation intensity at location

Returns:

  • (String)

    text representation of precipitation intensity at location

Since:

  • 0.1.4



81
82
83
# File 'lib/darksky-api/common-methods.rb', line 81

def precip_intensity_text
  _precip_intensity_text(precip_intensity)
end

#precip_probabilityNumeric

Returns current precipitation probability at location.

Examples:

location = DarkSky::Location.new [45, -90]
location.current.precip_probability #=> precipitation probability at location

Returns:

  • (Numeric)

    current precipitation probability at location

Since:

  • 0.1.4



90
91
92
# File 'lib/darksky-api/common-methods.rb', line 90

def precip_probability
  data[:precipProbability]
end

#precip_typeString | nil

Returns current precipitation type at location.

Examples:

location = DarkSky::Location.new [45, -90]
location.current.precip_type #=> precipitation type at location

Returns:

  • (String | nil)

    current precipitation type at location

Since:

  • 0.1.4



99
100
101
# File 'lib/darksky-api/common-methods.rb', line 99

def precip_type
  data[:precipType]
end

#pressureNumeric

Returns current barometric pressure at location.

Examples:

location = DarkSky::Location.new [45, -90]
location.current.pressure #=> barometric pressure at location

Returns:

  • (Numeric)

    current barometric pressure at location

Since:

  • 0.1.4



108
109
110
# File 'lib/darksky-api/common-methods.rb', line 108

def pressure
  data[:pressure]
end

#rainy?Boolean

Returns if icon is 'rain'.

Examples:

location = DarkSky::Location.new [45, -90]
location.current.rainy?

Returns:

  • (Boolean)

    if icon is 'rain'

Since:

  • 0.1.4



189
190
191
# File 'lib/darksky-api/common-methods.rb', line 189

def rainy?
  icon == 'rain'
end

#sleet?Boolean

Returns if icon is 'sleet'.

Examples:

location = DarkSky::Location.new [45, -90]
location.current.sleet?

Returns:

  • (Boolean)

    if icon is 'sleet'

Since:

  • 0.1.4



207
208
209
# File 'lib/darksky-api/common-methods.rb', line 207

def sleet?
  icon == 'sleet'
end

#snowy?Boolean

Returns if icon is 'snow'.

Examples:

location = DarkSky::Location.new [45, -90]
location.current.snowy?

Returns:

  • (Boolean)

    if icon is 'snow'

Since:

  • 0.1.4



198
199
200
# File 'lib/darksky-api/common-methods.rb', line 198

def snowy?
  icon == 'snow'
end

#summaryString

Returns summary of weather at location.

Examples:

location = DarkSky::Location.new [45, -90]
location.current.summary #=> summary of weather at location

Returns:

  • (String)

    summary of weather at location

Since:

  • 0.1.4



117
118
119
# File 'lib/darksky-api/common-methods.rb', line 117

def summary
  data[:summary]
end

#uv_indexNumeric

Returns current UV index at location.

Examples:

location = DarkSky::Location.new [45, -90]
location.current.uv_index #=> UV index at location

Returns:

  • (Numeric)

    current UV index at location

Since:

  • 0.1.4



126
127
128
# File 'lib/darksky-api/common-methods.rb', line 126

def uv_index
  data[:uvIndex]
end

#visibilityNumeric

Returns current visibility at location.

Examples:

location = DarkSky::Location.new [45, -90]
location.current.visibility #=> visibility at location

Returns:

  • (Numeric)

    current visibility at location

Since:

  • 0.1.4



135
136
137
# File 'lib/darksky-api/common-methods.rb', line 135

def visibility
  data[:visibility]
end

#wind_bearingNumeric

Returns current wind bearing at location.

Examples:

location = DarkSky::Location.new [45, -90]
location.current.wind_bearing #=> wind bearing at location

Returns:

  • (Numeric)

    current wind bearing at location

Since:

  • 0.1.4



144
145
146
# File 'lib/darksky-api/common-methods.rb', line 144

def wind_bearing
  data[:windBearing]
end

#wind_bearing_textString

Returns text representation of bearing.

Examples:

location = DarkSky::Location.new [45, -90]
location.current.wind_bearing_text #=> text representation of bearing (N, NW, etc.)

Returns:

  • (String)

    text representation of bearing

Since:

  • 0.1.4



153
154
155
# File 'lib/darksky-api/common-methods.rb', line 153

def wind_bearing_text
  _bearing_text(wind_bearing)
end

#wind_gustNumeric

Returns current wind gust at location.

Examples:

location = DarkSky::Location.new [45, -90]
location.current.wind_gust #=> wind gust at location

Returns:

  • (Numeric)

    current wind gust at location

Since:

  • 0.1.4



162
163
164
# File 'lib/darksky-api/common-methods.rb', line 162

def wind_gust
  data[:windGust]
end

#wind_speedNumeric

Returns current wind speed at location.

Examples:

location = DarkSky::Location.new [45, -90]
location.current.wind_speed #=> wind speed at location

Returns:

  • (Numeric)

    current wind speed at location

Since:

  • 0.1.4



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'.

Examples:

location = DarkSky::Location.new [45, -90]
location.current.windy?

Returns:

  • (Boolean)

    if icon is 'wind'

Since:

  • 0.1.4



216
217
218
# File 'lib/darksky-api/common-methods.rb', line 216

def windy?
  icon == 'wind'
end