Class: Fatigue::Run

Inherits:
Object
  • Object
show all
Defined in:
lib/fatigue/run.rb

Overview

RUN An individual run knows about its distance, time, and other fun.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#caloriesObject

Public: The number of calories burned in the run.



95
96
97
# File 'lib/fatigue/run.rb', line 95

def calories
  @calories
end

#descriptionObject

Public: The description of the run.



104
105
106
# File 'lib/fatigue/run.rb', line 104

def description
  @description
end

#distanceObject

Public: The distance of the run.



36
37
38
# File 'lib/fatigue/run.rb', line 36

def distance
  @distance
end

#durationObject

Public: The Integer duration of the run.



58
59
60
# File 'lib/fatigue/run.rb', line 58

def duration
  @duration.to_i
end

#nameObject

Public: The name of the run.



22
23
24
# File 'lib/fatigue/run.rb', line 22

def name
  @name
end

#serviceObject

Public: The name of the service used for this run.



13
14
15
# File 'lib/fatigue/run.rb', line 13

def service
  @service
end

#started_atObject

Public: The time the run was started.



84
85
86
# File 'lib/fatigue/run.rb', line 84

def started_at
  Time.iso8601 @started_at
end

#unitObject

Public: the full name of the distance unit.



45
46
47
48
49
50
# File 'lib/fatigue/run.rb', line 45

def unit
  case @unit
  when 'mi' then 'Miles'
  when 'km' then 'Kilometers'
  end
end

Instance Method Details

#formatted_nameObject

Public: The formatted name of the run. Includes service name.



25
26
27
# File 'lib/fatigue/run.rb', line 25

def formatted_name
  "#{service}#{name.strip == '' ? '' : ': '+name}"
end

#hoursObject

Public: The number of hours in the run (reduced).



73
74
75
# File 'lib/fatigue/run.rb', line 73

def hours
  (duration / 1000 / 60 / 60)
end

#minutesObject

Public: The number of minutes in the run (reduced).



68
69
70
# File 'lib/fatigue/run.rb', line 68

def minutes
  (duration / 1000 / 60) % 60
end

#secondsObject

Public: The number of seconds in the run (reduced).



63
64
65
# File 'lib/fatigue/run.rb', line 63

def seconds
  (duration / 1000) % 60
end