Class: Forecast::IO::Cache::ForecastData
- Inherits:
-
Struct
- Object
- Struct
- Forecast::IO::Cache::ForecastData
- Defined in:
- lib/forecast_io/cache/forecast_data.rb
Instance Attribute Summary collapse
-
#humidity ⇒ Object
Returns the value of attribute humidity.
-
#position ⇒ Object
Returns the value of attribute position.
-
#pressure ⇒ Object
Returns the value of attribute pressure.
-
#temperature ⇒ Object
Returns the value of attribute temperature.
-
#time ⇒ Object
Returns the value of attribute time.
-
#visibility ⇒ Object
Returns the value of attribute visibility.
-
#wind_bearing ⇒ Object
Returns the value of attribute wind_bearing.
-
#wind_speed ⇒ Object
Returns the value of attribute wind_speed.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#humidity ⇒ Object
Returns the value of attribute humidity
4 5 6 |
# File 'lib/forecast_io/cache/forecast_data.rb', line 4 def humidity @humidity end |
#position ⇒ Object
Returns the value of attribute position
4 5 6 |
# File 'lib/forecast_io/cache/forecast_data.rb', line 4 def position @position end |
#pressure ⇒ Object
Returns the value of attribute pressure
4 5 6 |
# File 'lib/forecast_io/cache/forecast_data.rb', line 4 def pressure @pressure end |
#temperature ⇒ Object
Returns the value of attribute temperature
4 5 6 |
# File 'lib/forecast_io/cache/forecast_data.rb', line 4 def temperature @temperature end |
#time ⇒ Object
Returns the value of attribute time
4 5 6 |
# File 'lib/forecast_io/cache/forecast_data.rb', line 4 def time @time end |
#visibility ⇒ Object
Returns the value of attribute visibility
4 5 6 |
# File 'lib/forecast_io/cache/forecast_data.rb', line 4 def visibility @visibility end |
#wind_bearing ⇒ Object
Returns the value of attribute wind_bearing
4 5 6 |
# File 'lib/forecast_io/cache/forecast_data.rb', line 4 def wind_bearing @wind_bearing end |
#wind_speed ⇒ Object
Returns the value of attribute wind_speed
4 5 6 |
# File 'lib/forecast_io/cache/forecast_data.rb', line 4 def wind_speed @wind_speed end |
Class Method Details
.generate(lat, lon, forecast) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/forecast_io/cache/forecast_data.rb', line 7 def self.generate lat, lon, forecast new.tap do |data| data.position = [lon,lat].map(&:to_f) data.time = forecast['time'] data.wind_speed = forecast['windSpeed'] data.wind_bearing = forecast['windBearing'] data.humidity = forecast['humidity'] data.pressure = forecast['pressure'] data.visibility = forecast['visibility'] data.temperature = forecast['temperature'] end end |
Instance Method Details
#to_json ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/forecast_io/cache/forecast_data.rb', line 20 def to_json { time: time, latitude: position[1], longitude: position[0], wind_speed: wind_speed, wind_bearing: wind_bearing, humidity: humidity, pressure: pressure, visibility: visibility, temperature: temperature } end |