Class TrackRecordReport::ReportElementaryCalculator
In: lib/track_record_report.rb
Parent: Object

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

Methods

add!   has_hours?   new   reset!   subtract!   total  

Attributes

committed  [RW]  Committed, not committed hours (floats)
not_committed  [RW]  Committed, not committed hours (floats)

Public Class methods

[Source]

    # File lib/track_record_report.rb, line 21
21:     def initialize
22:       reset!()
23:     end

Public Instance methods

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

[Source]

    # File lib/track_record_report.rb, line 40
40:     def add!( calculator )
41:       @committed     += calculator.committed
42:       @not_committed += calculator.not_committed
43:     end

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

[Source]

    # File lib/track_record_report.rb, line 33
33:     def has_hours?
34:       return ( total() > 0.0 )
35:     end

Reset the object‘s hour counts.

[Source]

    # File lib/track_record_report.rb, line 54
54:     def reset!
55:       @committed     = 0.0
56:       @not_committed = 0.0
57:     end

Opposite of ‘add!’.

[Source]

    # File lib/track_record_report.rb, line 47
47:     def subtract!( calculator )
48:       @committed     -= calculator.committed
49:       @not_committed -= calculator.not_committed
50:     end

Returns total worked hours (committed plus not committed).

[Source]

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

[Validate]