Class: TimeTap::Project::Pinch
- Inherits:
-
Object
- Object
- TimeTap::Project::Pinch
- Defined in:
- lib/time_tap/project.rb
Instance Attribute Summary collapse
-
#end_time ⇒ Object
Returns the value of attribute end_time.
-
#start_time ⇒ Object
Returns the value of attribute start_time.
Instance Method Summary collapse
- #duration ⇒ Object
- #humanized_duration ⇒ Object
-
#initialize(start_time) ⇒ Pinch
constructor
A new instance of Pinch.
Constructor Details
#initialize(start_time) ⇒ Pinch
Returns a new instance of Pinch.
96 97 98 |
# File 'lib/time_tap/project.rb', line 96 def initialize start_time @end_time = @start_time = start_time end |
Instance Attribute Details
#end_time ⇒ Object
Returns the value of attribute end_time.
95 96 97 |
# File 'lib/time_tap/project.rb', line 95 def end_time @end_time end |
#start_time ⇒ Object
Returns the value of attribute start_time.
95 96 97 |
# File 'lib/time_tap/project.rb', line 95 def start_time @start_time end |
Instance Method Details
#duration ⇒ Object
100 101 102 |
# File 'lib/time_tap/project.rb', line 100 def duration end_time ? end_time - start_time : 30.seconds end |
#humanized_duration ⇒ Object
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/time_tap/project.rb', line 104 def humanized_duration seconds = duration hours = mins = 0 if seconds >= 60 then mins = (seconds / 60).to_i seconds = (seconds % 60 ).to_i if mins >= 60 then hours = (mins / 60).to_i mins = (mins % 60).to_i end end "#{hours}h #{mins}m #{seconds}s" end |