class TrackRecordReport::ReportElementaryCalculator

Very simple base class used to store some common properties and methods for objects which deal with worked hours.

Attributes

committed[RW]

Committed, not committed hours (floats)

not_committed[RW]

Committed, not committed hours (floats)

Public Class Methods

new() click to toggle source
# File lib/track_record_report.rb, line 21
def initialize
  reset!()
end

Public Instance Methods

add!( calculator ) click to toggle source

Add the given calculator’s committed and not committed hours to this calculator’s hours.

# File lib/track_record_report.rb, line 40
def add!( calculator )
  @committed     += calculator.committed
  @not_committed += calculator.not_committed
end
has_hours?() click to toggle source

Returns ‘true’ if the object records > 0 total hours, else ‘false’.

# File lib/track_record_report.rb, line 33
def has_hours?
  return ( total() > 0.0 )
end
reset!() click to toggle source

Reset the object’s hour counts.

# File lib/track_record_report.rb, line 54
def reset!
  @committed     = 0.0
  @not_committed = 0.0
end
subtract!( calculator ) click to toggle source

Opposite of ‘add!’.

# File lib/track_record_report.rb, line 47
def subtract!( calculator )
  @committed     -= calculator.committed
  @not_committed -= calculator.not_committed
end
total() click to toggle source

Returns total worked hours (committed plus not committed).

# File lib/track_record_report.rb, line 27
def total
  return ( @committed + @not_committed )
end