Class: Tempo::Views::ViewRecords::TimeRecordContainer

Inherits:
Container
  • Object
show all
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

Attributes inherited from Container

#pre, #type

Instance Method Summary collapse

Methods inherited from Container

#records

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(options={})
  super options
  @type = "time_record_container"
  @duration = Duration.new
end

Instance Attribute Details

#durationObject

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

#postObject



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