Class: CycleHire::Journey
- Inherits:
-
Object
- Object
- CycleHire::Journey
- Defined in:
- lib/cycle_hire/journey.rb
Instance Attribute Summary collapse
-
#cost ⇒ Object
readonly
Returns the value of attribute cost.
-
#end_station ⇒ Object
readonly
Returns the value of attribute end_station.
-
#end_time ⇒ Object
readonly
Returns the value of attribute end_time.
-
#start_station ⇒ Object
readonly
Returns the value of attribute start_station.
-
#start_time ⇒ Object
readonly
Returns the value of attribute start_time.
Instance Method Summary collapse
- #duration ⇒ Object
-
#initialize(start_time, start_station, end_time, end_station, cost) ⇒ Journey
constructor
A new instance of Journey.
- #to_h ⇒ Object
Constructor Details
#initialize(start_time, start_station, end_time, end_station, cost) ⇒ Journey
Returns a new instance of Journey.
4 5 6 7 8 9 10 |
# File 'lib/cycle_hire/journey.rb', line 4 def initialize(start_time, start_station, end_time, end_station, cost) @start_time = start_time @start_station = start_station @end_time = end_time @end_station = end_station @cost = cost end |
Instance Attribute Details
#cost ⇒ Object (readonly)
Returns the value of attribute cost.
2 3 4 |
# File 'lib/cycle_hire/journey.rb', line 2 def cost @cost end |
#end_station ⇒ Object (readonly)
Returns the value of attribute end_station.
2 3 4 |
# File 'lib/cycle_hire/journey.rb', line 2 def end_station @end_station end |
#end_time ⇒ Object (readonly)
Returns the value of attribute end_time.
2 3 4 |
# File 'lib/cycle_hire/journey.rb', line 2 def end_time @end_time end |
#start_station ⇒ Object (readonly)
Returns the value of attribute start_station.
2 3 4 |
# File 'lib/cycle_hire/journey.rb', line 2 def start_station @start_station end |
#start_time ⇒ Object (readonly)
Returns the value of attribute start_time.
2 3 4 |
# File 'lib/cycle_hire/journey.rb', line 2 def start_time @start_time end |
Instance Method Details
#duration ⇒ Object
12 13 14 |
# File 'lib/cycle_hire/journey.rb', line 12 def duration ((@end_time - @start_time) / 60).to_i end |
#to_h ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/cycle_hire/journey.rb', line 16 def to_h { :start_time => @start_time, :start_station => @start_station.to_s, :end_time => @end_time, :end_station => @end_station.to_s, :cost => @cost, :duration => duration } end |