Sha256: dc1a98e5c2a0154d89460774608151fead742df3ab30400cc562ef96df53a34e

Contents?: true

Size: 1.44 KB

Versions: 8

Compression:

Stored size: 1.44 KB

Contents

class AutomobileMakeModel < ActiveRecord::Base
  set_primary_key :name
  
  belongs_to :make,                   :class_name => 'AutomobileMake',                 :foreign_key => 'make_name'
  has_many :make_model_year_variants, :class_name => 'AutomobileMakeModelYearVariant', :foreign_key => 'make_model_name'

  col :name # make + model
  col :make_name
  col :model_name # model only
  col :fuel_efficiency_city, :type => :float
  col :fuel_efficiency_city_units
  col :fuel_efficiency_highway, :type => :float
  col :fuel_efficiency_highway_units

  # TODO convert to table_warnings
  # verify "Fuel efficiencies should be greater than zero" do
  #   AutomobileMakeModel.all.each do |model|
  #     %w{ city highway }.each do |type|
  #       fuel_efficiency = model.send(:"fuel_efficiency_#{type}")
  #       unless fuel_efficiency > 0
  #         raise "Invalid fuel efficiency #{type} for AutomobileMakeModel #{model.name}: #{fuel_efficiency} (should be > 0)"
  #       end
  #     end
  #   end
  # end
  # 
  # verify "Fuel efficiency units should be kilometres per litre" do
  #   AutomobileMakeModel.all.each do |model|
  #     %w{ city highway }.each do |type|
  #       units = model.send(:"fuel_efficiency_#{type}_units")
  #       unless units == "kilometres_per_litre"
  #         raise "Invalid fuel efficiency #{type} units for AutomobileMakeModel #{model.name}: #{units} (should be kilometres_per_litre)"
  #       end
  #     end
  #   end
  # end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
earth-0.7.0 lib/earth/automobile/automobile_make_model.rb
earth-0.6.6 lib/earth/automobile/automobile_make_model.rb
earth-0.6.5 lib/earth/automobile/automobile_make_model.rb
earth-0.6.4 lib/earth/automobile/automobile_make_model.rb
earth-0.6.3 lib/earth/automobile/automobile_make_model.rb
earth-0.6.2 lib/earth/automobile/automobile_make_model.rb
earth-0.6.1 lib/earth/automobile/automobile_make_model.rb
earth-0.6.0 lib/earth/automobile/automobile_make_model.rb