Class: Tempo::Views::ViewRecords::TimeRecord
- Defined in:
- lib/tempo/views/view_records/time_record.rb
Overview
TimeRecord adds a description, project and end_time and running flag to the Log Record to represent any instance of the TimeRecord model. It also includes a Duration ViewRecord for presenting the total duration of the time record.
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#duration ⇒ Object
Returns the value of attribute duration.
-
#end_time ⇒ Object
Returns the value of attribute end_time.
-
#project ⇒ Object
Returns the value of attribute project.
-
#running ⇒ Object
Returns the value of attribute running.
Attributes inherited from Log
Attributes inherited from Model
Class Method Summary collapse
Instance Method Summary collapse
- #format(&block) ⇒ Object
-
#initialize(model, options = {}) ⇒ TimeRecord
constructor
A new instance of TimeRecord.
Constructor Details
#initialize(model, options = {}) ⇒ TimeRecord
Returns a new instance of TimeRecord.
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/tempo/views/view_records/time_record.rb', line 25 def initialize(model, ={}) super model, @description = model.description @description ||= "" @duration = Duration.new model.duration @end_time = model.end_time == :running ? Time.now().round : model.end_time @project = model.project_title @running = model.running? self.class.max_description_length @description.length self.class.max_project_length @project.length end |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
11 12 13 |
# File 'lib/tempo/views/view_records/time_record.rb', line 11 def description @description end |
#duration ⇒ Object
Returns the value of attribute duration.
11 12 13 |
# File 'lib/tempo/views/view_records/time_record.rb', line 11 def duration @duration end |
#end_time ⇒ Object
Returns the value of attribute end_time.
11 12 13 |
# File 'lib/tempo/views/view_records/time_record.rb', line 11 def end_time @end_time end |
#project ⇒ Object
Returns the value of attribute project.
11 12 13 |
# File 'lib/tempo/views/view_records/time_record.rb', line 11 def project @project end |
#running ⇒ Object
Returns the value of attribute running.
11 12 13 |
# File 'lib/tempo/views/view_records/time_record.rb', line 11 def running @running end |
Class Method Details
.max_description_length(len = 0) ⇒ Object
14 15 16 17 |
# File 'lib/tempo/views/view_records/time_record.rb', line 14 def max_description_length(len=0) @max_description_length ||= 0 @max_description_length = @max_description_length > len ? @max_description_length : len end |
.max_project_length(len = 0) ⇒ Object
19 20 21 22 |
# File 'lib/tempo/views/view_records/time_record.rb', line 19 def max_project_length(len=0) @max_project_length ||= 0 @max_project_length = @max_project_length > len ? @max_project_length : len end |
Instance Method Details
#format(&block) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/tempo/views/view_records/time_record.rb', line 37 def format(&block) block ||= lambda do |m| running = m.running ? "*" : " " description = @description ? "#{m.project}: #{m.description}" : "#{m.project}" "#{m.start_time.strftime('%H:%M')} - #{m.end_time.strftime('%H:%M')}#{running} [#{m.duration.format}] #{description}" end block.call self end |