Class: AutomobileActivityYear
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- AutomobileActivityYear
- Defined in:
- lib/earth/automobile/automobile_activity_year.rb
Class Method Summary collapse
-
.find_by_closest_year(year) ⇒ Object
Used by Automobile and AutomobileTrip.
Class Method Details
.find_by_closest_year(year) ⇒ Object
Used by Automobile and AutomobileTrip
8 9 10 11 12 13 14 |
# File 'lib/earth/automobile/automobile_activity_year.rb', line 8 def self.find_by_closest_year(year) if year > maximum(:activity_year) where(:activity_year => maximum(:activity_year)).first else where(:activity_year => [year, minimum(:activity_year)].max).first end end |