Class: AutomobileActivityYearType
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- AutomobileActivityYearType
- Defined in:
- lib/earth/automobile/automobile_activity_year_type.rb
Class Method Summary collapse
-
.find_by_type_name_and_closest_year(type_name, year) ⇒ Object
Used by Automobile and AutomobileTrip.
Instance Method Summary collapse
-
#activity_year_type_fuels ⇒ Object
for calculating hfc ef.
Class Method Details
.find_by_type_name_and_closest_year(type_name, year) ⇒ Object
Used by Automobile and AutomobileTrip
5 6 7 8 9 10 11 |
# File 'lib/earth/automobile/automobile_activity_year_type.rb', line 5 def self.find_by_type_name_and_closest_year(type_name, year) if year > maximum(:activity_year) where(:type_name => type_name, :activity_year => maximum(:activity_year)).first else where(:type_name => type_name, :activity_year => [year, minimum(:activity_year)].max).first end end |
Instance Method Details
#activity_year_type_fuels ⇒ Object
for calculating hfc ef
14 15 16 |
# File 'lib/earth/automobile/automobile_activity_year_type.rb', line 14 def activity_year_type_fuels AutomobileActivityYearTypeFuel.where(:activity_year => activity_year, :type_name => type_name) end |