Class: Tempo::Views::ViewRecords::TimeRecordContainer
- Defined in:
- lib/tempo/views/view_records/container.rb
Overview
Handle a collection of time records Pre can hold the title of the collection (date, project, etc.) postreturns the total duration of all contained records
Instance Attribute Summary collapse
-
#duration ⇒ Object
Returns the value of attribute duration.
Attributes inherited from Container
Instance Method Summary collapse
- #add(record) ⇒ Object
-
#initialize(options = {}) ⇒ TimeRecordContainer
constructor
A new instance of TimeRecordContainer.
- #post ⇒ Object
Methods inherited from Container
Constructor Details
#initialize(options = {}) ⇒ TimeRecordContainer
Returns a new instance of TimeRecordContainer.
50 51 52 53 54 |
# File 'lib/tempo/views/view_records/container.rb', line 50 def initialize(={}) super @type = "time_record_container" @duration = Duration.new end |
Instance Attribute Details
#duration ⇒ Object
Returns the value of attribute duration.
48 49 50 |
# File 'lib/tempo/views/view_records/container.rb', line 48 def duration @duration end |
Instance Method Details
#add(record) ⇒ Object
56 57 58 59 60 |
# File 'lib/tempo/views/view_records/container.rb', line 56 def add(record) # TODO: fail if not a time record super record @duration.add record.duration.total end |
#post ⇒ Object
62 63 64 |
# File 'lib/tempo/views/view_records/container.rb', line 62 def post ViewRecords::Message.new "Total: ------- [#{duration.format}] --------------------------------\n\n", postpone: true end |