Class: Bike
Instance Attribute Summary collapse
-
#distance ⇒ Object
Returns the value of attribute distance.
-
#speed ⇒ Object
Returns the value of attribute speed.
Instance Method Summary collapse
- #compute_time ⇒ Object
-
#initialize(distance, speed) ⇒ Bike
constructor
A new instance of Bike.
- #to_s ⇒ Object
Methods included from TimePresenter
#present_hours_as_string, #present_seconds_as_string
Constructor Details
#initialize(distance, speed) ⇒ Bike
Returns a new instance of Bike.
6 7 8 9 |
# File 'lib/bike.rb', line 6 def initialize(distance, speed) self.distance = distance.to_f self.speed = speed.to_f end |
Instance Attribute Details
#distance ⇒ Object
Returns the value of attribute distance.
4 5 6 |
# File 'lib/bike.rb', line 4 def distance @distance end |
#speed ⇒ Object
Returns the value of attribute speed.
4 5 6 |
# File 'lib/bike.rb', line 4 def speed @speed end |
Instance Method Details
#compute_time ⇒ Object
11 12 13 14 |
# File 'lib/bike.rb', line 11 def compute_time time = distance / speed # time in hours present_hours_as_string(time) end |
#to_s ⇒ Object
16 17 18 19 |
# File 'lib/bike.rb', line 16 def to_s p distance p speed end |