Class: Overtimer::Workbase

Inherits:
Object
  • Object
show all
Defined in:
lib/overtimer/workbase.rb

Direct Known Subclasses

Workday, Workweek

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Workbase

Returns a new instance of Workbase.



17
18
19
20
21
22
# File 'lib/overtimer/workbase.rb', line 17

def initialize *args
  @total = 0
  @regular = 0
  @overtime = 0
  @doubletime = 0
end

Instance Attribute Details

#doubletimeObject

Returns the value of attribute doubletime.



4
5
6
# File 'lib/overtimer/workbase.rb', line 4

def doubletime
  @doubletime
end

#overtimeObject

Returns the value of attribute overtime.



3
4
5
# File 'lib/overtimer/workbase.rb', line 3

def overtime
  @overtime
end

#regularObject

Returns the value of attribute regular.



3
4
5
# File 'lib/overtimer/workbase.rb', line 3

def regular
  @regular
end

#totalObject (readonly)

Returns the value of attribute total.



3
4
5
# File 'lib/overtimer/workbase.rb', line 3

def total
  @total
end

Instance Method Details

#account_for_hours(hours) ⇒ Object



42
43
44
45
46
47
48
49
# File 'lib/overtimer/workbase.rb', line 42

def  hours
  if @regular <= max_regular
    self.regular += hours
  else
    self.overtime += hours
  end
  @total += hours
end

#max_overtimeObject



9
10
11
12
13
14
15
# 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_regularObject



5
6
7
# File 'lib/overtimer/workbase.rb', line 5

def max_regular
  self.class.max_regular
end