Class: MyWeatherForecast::Daily
- Inherits:
-
Hourly
- Object
- Hourly
- MyWeatherForecast::Daily
show all
- Defined in:
- lib/myweatherforecast.rb
Instance Attribute Summary
Attributes inherited from Hourly
#today
Instance Method Summary
collapse
Methods inherited from Hourly
#afternoon, #ahead, #at, #detail, #early_hours, #emoji, #evening, #humidity, #icon, #morning, #night, #noon, #summary, #time, #visibility, #windspeed
Constructor Details
#initialize(forecast, tlabel, d = 0) ⇒ Daily
Returns a new instance of Daily.
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
|
# File 'lib/myweatherforecast.rb', line 228
def initialize(forecast, tlabel, d=0)
@forecast = forecast
@x = forecast['daily']['data'][d]
@tlabel = tlabel
found = forecast['hourly']['data'].detect do |hour|
Time.at(@x.time).to_date == Time.at(hour.time).to_date
end
@i = forecast['hourly']['data'].index found
return if @i.nil?
@hourly_data = forecast['hourly']['data'][@i..-1]
@day = self
end
|
Instance Method Details
#day ⇒ Object
248
249
250
|
# File 'lib/myweatherforecast.rb', line 248
def day()
Date::ABBR_DAYNAMES[self.time.wday]
end
|
#sunrise ⇒ Object
260
261
262
|
# File 'lib/myweatherforecast.rb', line 260
def sunrise()
Time.at @x.sunriseTime
end
|
#sunset ⇒ Object
264
265
266
|
# File 'lib/myweatherforecast.rb', line 264
def sunset()
Time.at @x.sunsetTime
end
|
#temperature ⇒ Object
268
269
|
# File 'lib/myweatherforecast.rb', line 268
def temperature()
end
|
#tempmax ⇒ Object
275
276
277
|
# File 'lib/myweatherforecast.rb', line 275
def tempmax
"%s°" % [@x.temperatureMax.round]
end
|
#tempmin ⇒ Object
271
272
273
|
# File 'lib/myweatherforecast.rb', line 271
def tempmin
"%s°" % [@x.temperatureMin.round]
end
|
#to_s ⇒ Object
252
253
254
255
256
257
258
|
# File 'lib/myweatherforecast.rb', line 252
def to_s
label = self.time.to_date == Time.now.to_date ? 'Today' : day()
mask = @symbols ? "%s: ▽%s ▲%s, %s" : "%s: %s %s, %s"
mask % [label, tempmin, tempmax, @x.summary]
end
|