Sha256: e17e8747e13d284303fcf4227757e4ab4de5ee264de4bff9f7aa7dbbdf9ecd04
Contents?: true
Size: 1.43 KB
Versions: 4
Compression:
Stored size: 1.43 KB
Contents
require 'earth/model' require 'earth/automobile/automobile_type_fuel_year_control' class AutomobileTypeFuelYear < ActiveRecord::Base extend Earth::Model TABLE_STRUCTURE = <<-EOS CREATE TABLE automobile_type_fuel_years ( name CHARACTER VARYING(255) NOT NULL PRIMARY KEY, type_name CHARACTER VARYING(255), fuel_family CHARACTER VARYING(255), year INTEGER, share_of_type FLOAT, annual_distance FLOAT, annual_distance_units CHARACTER VARYING(255), ch4_emission_factor FLOAT, ch4_emission_factor_units CHARACTER VARYING(255), n2o_emission_factor FLOAT, n2o_emission_factor_units CHARACTER VARYING(255) ); EOS self.primary_key = "name" # Used by Automobile and AutomobileTrip def self.find_by_type_name_and_fuel_family_and_closest_year(type_name, fuel_family, year) return if (candidates = where(:type_name => type_name, :fuel_family => fuel_family)).none? if year > (max_year = candidates.maximum(:year)) candidates.where(:year => max_year).first else candidates.where(:year => [year, candidates.minimum(:year)].max).first end end # for calculating ch4 and n2o ef def type_fuel_year_controls AutomobileTypeFuelYearControl.find_all_by_type_name_and_fuel_family_and_closest_year(type_name, fuel_family, year) end warn_unless_size 124 end
Version data entries
4 entries across 4 versions & 1 rubygems