Class: TimeTap::Project::Pinch

Inherits:
Object
  • Object
show all
Defined in:
lib/time_tap/project.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_timeObject

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_timeObject

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

#durationObject



100
101
102
# File 'lib/time_tap/project.rb', line 100

def duration
  end_time ? end_time - start_time : 30.seconds
end

#humanized_durationObject



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