Class: Runby::Pace

Inherits:
Object
  • Object
show all
Defined in:
lib/runby_pace/pace.rb

Overview

Represents a pace consisting of a distance and a time in which that distance was covered

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(time, distance = '1K') ⇒ Pace

Returns a new instance of Pace.



5
6
7
8
# File 'lib/runby_pace/pace.rb', line 5

def initialize(time, distance = '1K')
  @time = Runby::RunbyTime.parse(time)
  @distance = Runby::Distance.new(distance)
end

Instance Attribute Details

#distance ⇒ Object (readonly)

Returns the value of attribute distance.



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

def distance
  @distance
end

#time ⇒ Object (readonly)

Returns the value of attribute time.



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

def time
  @time
end

Instance Method Details

#to_s ⇒ Object



10
11
12
# File 'lib/runby_pace/pace.rb', line 10

def to_s
  "#{time} per #{distance.pluralized_uom}"
end