Class: Forecast::Collection
- Inherits:
-
Array
- Object
- Array
- Forecast::Collection
- Defined in:
- lib/forecast/collection.rb
Instance Method Summary collapse
Instance Method Details
#select_date(date) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/forecast/collection.rb', line 3 def select_date(date) result = nil date_forecasts = self.select do |obj| obj.date.to_date == date.to_date end if date_forecasts.length == 0 return nil else hour_forecasts = date_forecasts.select do |obj| obj.date.hour == obj.date.hour end if hour_forecasts.length > 0 return hour_forecasts.first end return date_forecasts.first end return nil end |