Class: Fatigue::Run
- Inherits:
-
Object
- Object
- Fatigue::Run
- Defined in:
- lib/fatigue/run.rb
Overview
RUN An individual run knows about its distance, time, and other fun.
Instance Attribute Summary collapse
-
#calories ⇒ Object
Public: The number of calories burned in the run.
-
#description ⇒ Object
Public: The description of the run.
-
#distance ⇒ Object
Public: The distance of the run.
-
#duration ⇒ Object
Public: The Integer duration of the run.
-
#name ⇒ Object
Public: The name of the run.
-
#service ⇒ Object
Public: The name of the service used for this run.
-
#started_at ⇒ Object
Public: The time the run was started.
-
#unit ⇒ Object
Public: the full name of the distance unit.
Instance Method Summary collapse
-
#formatted_name ⇒ Object
Public: The formatted name of the run.
-
#hours ⇒ Object
Public: The number of hours in the run (reduced).
-
#minutes ⇒ Object
Public: The number of minutes in the run (reduced).
-
#seconds ⇒ Object
Public: The number of seconds in the run (reduced).
Instance Attribute Details
#calories ⇒ Object
Public: The number of calories burned in the run.
95 96 97 |
# File 'lib/fatigue/run.rb', line 95 def calories @calories end |
#description ⇒ Object
Public: The description of the run.
104 105 106 |
# File 'lib/fatigue/run.rb', line 104 def description @description end |
#distance ⇒ Object
Public: The distance of the run.
36 37 38 |
# File 'lib/fatigue/run.rb', line 36 def distance @distance end |
#duration ⇒ Object
Public: The Integer duration of the run.
58 59 60 |
# File 'lib/fatigue/run.rb', line 58 def duration @duration.to_i end |
#name ⇒ Object
Public: The name of the run.
22 23 24 |
# File 'lib/fatigue/run.rb', line 22 def name @name end |
#service ⇒ Object
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_at ⇒ Object
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 |
#unit ⇒ Object
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_name ⇒ Object
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 |
#hours ⇒ Object
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 |
#minutes ⇒ Object
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 |
#seconds ⇒ Object
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 |