class AutomobileFuel
Constants
- TABLE_STRUCTURE
Public Class Methods
determine_fallback(method)
click to toggle source
# File lib/earth/automobile/automobile_fuel.rb, line 62 def determine_fallback(method) if method =~ /units/ gasoline.send(method) else (fallback_blend_portion * diesel.send(method)) + ((1 - fallback_blend_portion) * gasoline.send(method)) end end
diesel()
click to toggle source
# File lib/earth/automobile/automobile_fuel.rb, line 50 def diesel find 'diesel' end
fallback_blend_portion()
click to toggle source
# File lib/earth/automobile/automobile_fuel.rb, line 58 def fallback_blend_portion diesel.total_consumption / (diesel.total_consumption + gasoline.total_consumption) end
gasoline()
click to toggle source
# File lib/earth/automobile/automobile_fuel.rb, line 54 def gasoline find 'gasoline' end
Public Instance Methods
non_liquid?()
click to toggle source
Used by Automobile and AutomobileTrip to determine whether need to convert fuel efficiency units
# File lib/earth/automobile/automobile_fuel.rb, line 72 def non_liquid? energy_content_units != 'megajoules_per_litre' end
same_as?(other_auto_fuel)
click to toggle source
Used by Automobile and AutomobileTrip to check whether user-input fuel matches one of the vehicle’s fuels
# File lib/earth/automobile/automobile_fuel.rb, line 77 def same_as?(other_auto_fuel) unless other_auto_fuel.nil? if ['G', 'R', 'P'].include? self.code ['G', 'R', 'P'].include? other_auto_fuel.code else self == other_auto_fuel end end end
suffix()
click to toggle source
for AutomobileMakeModel.custom_find
# File lib/earth/automobile/automobile_fuel.rb, line 88 def suffix case code when 'D', 'BP-B5', 'BP-B20', 'BP-B100' 'DIESEL' when 'E' 'FFV' when 'C' 'CNG' end end