class Overtimer::Workbase

Attributes

doubletime[RW]
overtime[R]
regular[R]
total[R]

Public Class Methods

new(*args) click to toggle source
# File lib/overtimer/workbase.rb, line 17
def initialize *args
  @total = 0
  @regular = 0
  @overtime = 0
  @doubletime = 0
end

Public Instance Methods

account_for_hours(hours) click to toggle source
# File lib/overtimer/workbase.rb, line 42
def account_for_hours hours
  if @regular <= max_regular
    self.regular += hours
  else
    self.overtime += hours
  end
  @total += hours
end
max_overtime() click to toggle source
# File lib/overtimer/workbase.rb, line 9
def max_overtime
  if self.class.respond_to? :max_overtime
    self.class.max_overtime
  else
    999
  end
end
max_regular() click to toggle source
# File lib/overtimer/workbase.rb, line 5
def max_regular
  self.class.max_regular
end
overtime=(val) click to toggle source
# File lib/overtimer/workbase.rb, line 33
def overtime=(val)
  @overtime = val
  if @overtime >= max_overtime
    overflow = @overtime - max_overtime
    self.doubletime += overflow
    @overtime -= overflow
  end
end
regular=(val) click to toggle source
# File lib/overtimer/workbase.rb, line 24
def regular=(val)
  @regular = val
  if @regular >= max_regular
    overflow = @regular - max_regular
    self.overtime += overflow
    @regular -= overflow
  end
end