Method: AutomobileFuel#same_as?

Defined in:
lib/earth/automobile/automobile_fuel.rb

#same_as?(other_auto_fuel) ⇒ Boolean

Used by Automobile and AutomobileTrip to check whether user-input fuel matches one of the vehicle’s fuels

Returns:

  • (Boolean)


77
78
79
80
81
82
83
84
85
# 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