Class: AutomobileMakeModel
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- AutomobileMakeModel
- Extended by:
- Earth::Model
- Defined in:
- lib/earth/automobile/automobile_make_model.rb
Constant Summary collapse
- TABLE_STRUCTURE =
"\nCREATE TABLE automobile_make_models\n (\n name CHARACTER VARYING(255) NOT NULL PRIMARY KEY,\n make_name CHARACTER VARYING(255),\n model_name CHARACTER VARYING(255),\n fuel_code CHARACTER VARYING(255),\n fuel_efficiency_city FLOAT,\n fuel_efficiency_city_units CHARACTER VARYING(255),\n fuel_efficiency_highway FLOAT,\n fuel_efficiency_highway_units CHARACTER VARYING(255),\n alt_fuel_code CHARACTER VARYING(255),\n alt_fuel_efficiency_city FLOAT,\n alt_fuel_efficiency_city_units CHARACTER VARYING(255),\n alt_fuel_efficiency_highway FLOAT,\n alt_fuel_efficiency_highway_units CHARACTER VARYING(255),\n type_name CHARACTER VARYING(255)\n );\n\n"
Class Method Summary collapse
-
.custom_find(characteristics) ⇒ Object
Used by Automobile and AutomobileTrip to look up a make model year considering fuel.
Instance Method Summary collapse
-
#model_years ⇒ Object
for deriving fuel codes and type name.
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_years ⇒ Object
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 |