Class: WeatherData
- Inherits:
-
Object
- Object
- WeatherData
- Defined in:
- lib/weather_data.rb
Constant Summary collapse
- NYC =
[40.714623, -74.006605]
- NYC_LAT =
- NYC_LONG =
Instance Attribute Summary collapse
-
#lat ⇒ Object
Returns the value of attribute lat.
-
#long ⇒ Object
Returns the value of attribute long.
-
#today_data ⇒ Object
Returns the value of attribute today_data.
-
#yesterday_data ⇒ Object
Returns the value of attribute yesterday_data.
Instance Method Summary collapse
-
#initialize(lat = NYC_LAT, long = NYC_LONG) ⇒ WeatherData
constructor
A new instance of WeatherData.
- #temp_today ⇒ Object
- #temp_tomorrow ⇒ Object
- #temp_yesterday ⇒ Object
- #time_yesterday ⇒ Object
Constructor Details
#initialize(lat = NYC_LAT, long = NYC_LONG) ⇒ WeatherData
Returns a new instance of WeatherData.
9 10 11 12 13 14 |
# File 'lib/weather_data.rb', line 9 def initialize(lat = NYC_LAT, long = NYC_LONG) @lat = lat @long = long puts "checking my instruments" @today_data = ForecastIO.forecast(self.lat, self.long, time: Time.now.to_i) end |
Instance Attribute Details
#lat ⇒ Object
Returns the value of attribute lat.
3 4 5 |
# File 'lib/weather_data.rb', line 3 def lat @lat end |
#long ⇒ Object
Returns the value of attribute long.
3 4 5 |
# File 'lib/weather_data.rb', line 3 def long @long end |
#today_data ⇒ Object
Returns the value of attribute today_data.
3 4 5 |
# File 'lib/weather_data.rb', line 3 def today_data @today_data end |
#yesterday_data ⇒ Object
Returns the value of attribute yesterday_data.
3 4 5 |
# File 'lib/weather_data.rb', line 3 def yesterday_data @yesterday_data end |
Instance Method Details
#temp_today ⇒ Object
21 22 23 |
# File 'lib/weather_data.rb', line 21 def temp_today self.today_data["currently"]["temperature"] end |
#temp_tomorrow ⇒ Object
25 26 27 |
# File 'lib/weather_data.rb', line 25 def temp_tomorrow self.today_data["hourly"]["data"][23]["temperature"] end |
#temp_yesterday ⇒ Object
16 17 18 19 |
# File 'lib/weather_data.rb', line 16 def temp_yesterday @yesterday_data = ForecastIO.forecast(self.lat, self.long, time: time_yesterday) self.yesterday_data["currently"]["temperature"] end |
#time_yesterday ⇒ Object
29 30 31 |
# File 'lib/weather_data.rb', line 29 def time_yesterday Time.now.to_i - 86400 end |