Class: AutomobileMakeModel

Inherits:
ActiveRecord::Base
  • Object
show all
Extended by:
Earth::Model
Defined in:
lib/earth/automobile/automobile_make_model.rb

Constant Summary collapse

TABLE_STRUCTURE =
<<-EOS

CREATE TABLE automobile_make_models
  (
     name                              CHARACTER VARYING(255) NOT NULL PRIMARY KEY,
     make_name                         CHARACTER VARYING(255),
     model_name                        CHARACTER VARYING(255),
     fuel_code                         CHARACTER VARYING(255),
     fuel_efficiency_city              FLOAT,
     fuel_efficiency_city_units        CHARACTER VARYING(255),
     fuel_efficiency_highway           FLOAT,
     fuel_efficiency_highway_units     CHARACTER VARYING(255),
     alt_fuel_code                     CHARACTER VARYING(255),
     alt_fuel_efficiency_city          FLOAT,
     alt_fuel_efficiency_city_units    CHARACTER VARYING(255),
     alt_fuel_efficiency_highway       FLOAT,
     alt_fuel_efficiency_highway_units CHARACTER VARYING(255),
     type_name                         CHARACTER VARYING(255)
  );

EOS

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Earth::Model

extend_mining, extended, registry

Class Method Details

.custom_find(characteristics) ⇒ Object

Used by Automobile and AutomobileTrip to look up a make model year considering fuel



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/earth/automobile/automobile_make_model.rb', line 38

def self.custom_find(characteristics)
  if characteristics[:make] and characteristics[:model]
    # append fuel suffix to model name and search
    make_model = if characteristics[:automobile_fuel]
      find_by_make_name_and_model_name characteristics[:make].name, [characteristics[:model].name, characteristics[:automobile_fuel].suffix].join(' ')
    end
    
    # use original model name if fuel suffix didn't help
    make_model ? make_model : find_by_make_name_and_model_name(characteristics[:make].name, characteristics[:model].name)
  end
end

Instance Method Details

#model_yearsObject

for deriving fuel codes and type name



51
52
53
# File 'lib/earth/automobile/automobile_make_model.rb', line 51

def model_years
  AutomobileMakeModelYear.where(:make_name => make_name, :model_name => model_name)
end