class Tempo::Views::ViewRecords::TimeRecord
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.
Attributes
description[RW]
duration[RW]
end_time[RW]
project[RW]
running[RW]
Public Class Methods
max_description_length(len=0)
click to toggle source
# 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)
click to toggle source
# 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
new(model, options={})
click to toggle source
Calls superclass method
Tempo::Views::ViewRecords::Log::new
# File lib/tempo/views/view_records/time_record.rb, line 25 def initialize(model, options={}) super model, options @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
Public Instance Methods
format(&block)
click to toggle source
# 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