class BillTrap::Entry

Attributes

round[RW]

Public Class Methods

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

Public Instance Methods

date() click to toggle source
# File lib/billtrap/models.rb, line 172
def date
 start.to_date
end
duration() click to toggle source
# File lib/billtrap/models.rb, line 196
def duration
  @duration ||= self.end_or_now.to_i - self.start.to_i
end
end() click to toggle source
# File lib/billtrap/models.rb, line 188
def end
  round? ? rounded_end : self[:end]
end
end=(time) click to toggle source
# File lib/billtrap/models.rb, line 180
def end= time
  self[:end]= Timer.process_time(time)
end
end_or_now() click to toggle source
# File lib/billtrap/models.rb, line 205
def end_or_now
  self.end || (round? ? round(Time.now) : Time.now)
end
round(time, roundsecs=BillTrap::Config['round_in_seconds']) click to toggle source
# File lib/billtrap/models.rb, line 217
def round time, roundsecs=BillTrap::Config['round_in_seconds']
  return nil unless time
  Time.at(
    if (r = time.to_i % roundsecs) < 450
      time.to_i - r
    else
      time.to_i + (roundsecs - r)
    end
    )
end
round?() click to toggle source
# File lib/billtrap/models.rb, line 168
def round?
  !!self.class.round
end
rounded_end() click to toggle source
# File lib/billtrap/models.rb, line 213
def rounded_end
  round(self[:end])
end
rounded_start() click to toggle source
# File lib/billtrap/models.rb, line 209
def rounded_start
  round(self[:start])
end
sheet() click to toggle source
# File lib/billtrap/models.rb, line 192
def sheet
  self[:sheet].to_s
end
start() click to toggle source
# File lib/billtrap/models.rb, line 184
def start
  round? ? rounded_start : self[:start]
end
start=(time) click to toggle source
# File lib/billtrap/models.rb, line 176
def start= time
 self[:start]= Timer.process_time(time)
end