Sha256: a8896a2a4c1cdbdd42e4804d1e071b13d8d2504cfbc1ec28b2aaa36be0a1fae7
Contents?: true
Size: 1.42 KB
Versions: 3
Compression:
Stored size: 1.42 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) candidates = where(:type_name => type_name, :fuel_family => fuel_family) 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
earth-1.0.3 | lib/earth/automobile/automobile_type_fuel_year.rb |
earth-1.0.2 | lib/earth/automobile/automobile_type_fuel_year.rb |
earth-1.0.1 | lib/earth/automobile/automobile_type_fuel_year.rb |