Class: Energy::AutomobileTrip

Inherits:
Consumer
  • Object
show all
Defined in:
lib/energy/automobile_trip.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ AutomobileTrip

:nodoc:



13
14
15
16
17
18
# File 'lib/energy/automobile_trip.rb', line 13

def initialize(attrs = {}) # :nodoc:
  attrs = attrs.symbolize_keys
  @make = attrs[:make]
  @model = attrs[:model]
  @distance = attrs[:distance]
end

Instance Attribute Details

#distanceObject

Returns the value of attribute distance.



5
6
7
# File 'lib/energy/automobile_trip.rb', line 5

def distance
  @distance
end

#makeObject

Returns the value of attribute make.



3
4
5
# File 'lib/energy/automobile_trip.rb', line 3

def make
  @make
end

#modelObject

Returns the value of attribute model.



4
5
6
# File 'lib/energy/automobile_trip.rb', line 4

def model
  @model
end

Class Method Details

.fuel_use(attrs = {}) ⇒ Object

Estimate the fuel used by an automobile trip given any of the following optional characteristics:

  • make - “nissan”

  • model - “altima”

  • distance - 500 (kilometres)

See carbon.brighterplanet.com/models/rail_trip for more details



26
27
28
# File 'lib/energy/automobile_trip.rb', line 26

def fuel_use(attrs = {})
  estimate :fuel_use, attrs
end