class AutomobileActivityYearType

Constants

TABLE_STRUCTURE

Public Class Methods

find_by_type_name_and_closest_year(type_name, year) click to toggle source

Used by Automobile and AutomobileTrip

# File lib/earth/automobile/automobile_activity_year_type.rb, line 26
def self.find_by_type_name_and_closest_year(type_name, year)
  return if (candidates = where(:type_name => type_name)).none?
  if year > (max_year = candidates.maximum(:activity_year))
    candidates.where(:activity_year => max_year).first
  else
    candidates.where(:activity_year => [year, candidates.minimum(:activity_year)].max).first
  end
end

Public Instance Methods

activity_year_type_fuels() click to toggle source

for calculating hfc ef

# File lib/earth/automobile/automobile_activity_year_type.rb, line 36
def activity_year_type_fuels
  AutomobileActivityYearTypeFuel.where(:activity_year => activity_year, :type_name => type_name)
end