class Timetrap::Entry
Attributes
Public Class Methods
sheets()
click to toggle source
# File lib/timetrap/models.rb, line 64 def self.sheets map{|e|e.sheet}.uniq.sort end
Public Instance Methods
duration()
click to toggle source
# File lib/timetrap/models.rb, line 34 def duration @duration ||= self.end_or_now.to_i - self.start.to_i end
duration=( nd )
click to toggle source
# File lib/timetrap/models.rb, line 37 def duration=( nd ) @duration = nd.to_i end
end()
click to toggle source
# File lib/timetrap/models.rb, line 26 def end round? ? rounded_end : self[:end] end
end=(time)
click to toggle source
# File lib/timetrap/models.rb, line 18 def end= time self[:end]= Timer.process_time(time) end
end_or_now()
click to toggle source
# File lib/timetrap/models.rb, line 41 def end_or_now self.end || (round? ? round(Time.now) : Time.now) end
round(time)
click to toggle source
# File lib/timetrap/models.rb, line 53 def round time return nil unless time Time.at( if (r = time.to_i % Timetrap::Config['round_in_seconds']) < 450 time.to_i - r else time.to_i + (Timetrap::Config['round_in_seconds'] - r) end ) end
round?()
click to toggle source
# File lib/timetrap/models.rb, line 10 def round? !!self.class.round end
rounded_end()
click to toggle source
# File lib/timetrap/models.rb, line 49 def rounded_end round(self[:end]) end
rounded_start()
click to toggle source
# File lib/timetrap/models.rb, line 45 def rounded_start round(self[:start]) end
sheet()
click to toggle source
# File lib/timetrap/models.rb, line 30 def sheet self[:sheet].to_s end
start()
click to toggle source
# File lib/timetrap/models.rb, line 22 def start round? ? rounded_start : self[:start] end
start=(time)
click to toggle source
# File lib/timetrap/models.rb, line 14 def start= time self[:start]= Timer.process_time(time) end