Class: Bike

Inherits:
Object
  • Object
show all
Includes:
TimePresenter
Defined in:
lib/bike.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#distanceObject

Returns the value of attribute distance.



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

def distance
  @distance
end

#speedObject

Returns the value of attribute speed.



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

def speed
  @speed
end

Instance Method Details

#compute_timeObject



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_sObject



16
17
18
19
# File 'lib/bike.rb', line 16

def to_s
  p distance
  p speed
end