Parent

Timetrap::Entry

Attributes

round[RW]

a class level instance variable that controls whether or not all entries should respond to start and end with times rounded to 15 minute increments.

Public Class Methods

sheets() click to toggle source
# File lib/timetrap/models.rb, line 66
def self.sheets
  map{|e|e.sheet}.uniq.sort
end

Public Instance Methods

duration() click to toggle source
# File lib/timetrap/models.rb, line 36
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 39
def duration=( nd )
  @duration = nd.to_i
end
end(= time) click to toggle source
# File lib/timetrap/models.rb, line 20
def end= time
  self[:end]= Timer.process_time(time)
end
end_or_now() click to toggle source
# File lib/timetrap/models.rb, line 43
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 55
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 12
def round?
  !!self.class.round
end
rounded_end() click to toggle source
# File lib/timetrap/models.rb, line 51
def rounded_end
  round(self[:end])
end
rounded_start() click to toggle source
# File lib/timetrap/models.rb, line 47
def rounded_start
  round(self[:start])
end
sheet() click to toggle source
# File lib/timetrap/models.rb, line 32
def sheet
  self[:sheet].to_s
end
start() click to toggle source
# File lib/timetrap/models.rb, line 24
def start
  round? ? rounded_start : self[:start]
end
start=(time) click to toggle source
# File lib/timetrap/models.rb, line 16
def start= time
  self[:start]= Timer.process_time(time)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.