Class: Swim
Instance Method Summary
collapse
#present_hours_as_string, #present_seconds_as_string
Constructor Details
#initialize(pace_string, distance = 0.0) ⇒ Swim
Returns a new instance of Swim.
5
6
7
8
9
|
# File 'lib/swim.rb', line 5
def initialize(pace_string, distance=0.0)
converter = Converter.new
@pace = converter.string_to_seconds pace_string
@distance = distance
end
|
Instance Method Details
#compute_time(distance = @distance) ⇒ Object
25
26
27
28
29
|
# File 'lib/swim.rb', line 25
def compute_time(distance=@distance)
hundreds = distance.to_f / 100.0
time_in_seconds = @pace * hundreds
present_seconds_as_string time_in_seconds
end
|
#distance ⇒ Object
21
22
23
|
# File 'lib/swim.rb', line 21
def distance
@distance
end
|
#pace ⇒ Object
17
18
19
|
# File 'lib/swim.rb', line 17
def pace
present_seconds_as_string @pace
end
|
#split(split_distance) ⇒ Object
11
12
13
14
15
|
# File 'lib/swim.rb', line 11
def split(split_distance)
ratio = split_distance.to_f / 100.0
split = @pace * ratio
present_seconds_as_string split
end
|