Class: Tempo::Views::Formatters::Screen
- Defined in:
- lib/tempo/views/formatters/screen.rb
Instance Method Summary collapse
-
#active_indicator(project) ⇒ Object
spacer for project titles, active project marked with *.
- #duration_block(record) ⇒ Object
- #id_partial(id) ⇒ Object
- #message_block(record) ⇒ Object
- #project_block(record) ⇒ Object
- #tag_partial(tags, title_length) ⇒ Object
- #timerecord_block(record) ⇒ Object
Methods inherited from Base
Instance Method Details
#active_indicator(project) ⇒ Object
spacer for project titles, active project marked with *
35 36 37 |
# File 'lib/tempo/views/formatters/screen.rb', line 35 def active_indicator(project) indicator = project.current ? "* " : " " end |
#duration_block(record) ⇒ Object
28 29 30 31 32 |
# File 'lib/tempo/views/formatters/screen.rb', line 28 def duration_block(record) record.format do |d| puts "#{ d.hours.to_s }:#{ d.minutes.to_s.rjust(2, '0') }" end end |
#id_partial(id) ⇒ Object
53 54 55 |
# File 'lib/tempo/views/formatters/screen.rb', line 53 def id_partial(id) @options[:id] ? "[#{id}] ".rjust(6, ' ') : "" end |
#message_block(record) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/tempo/views/formatters/screen.rb', line 16 def (record) record.format do |m| case m.category when :error raise m. when :info, :debug puts m. end m. end end |
#project_block(record) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/tempo/views/formatters/screen.rb', line 57 def project_block(record) record.format do |r| @options[:active] = @options.fetch( :active, false ) record = r.title id = id_partial r.id active = @options[:active] ? active_indicator( r ) : "" depth = @options[:depth] ? " " * r.depth : "" title = r.title view = "#{id}#{active}#{depth}#{title}" = @options[:tags] ? tag_partial( r., view.length ) : "" view += puts view end end |
#tag_partial(tags, title_length) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/tempo/views/formatters/screen.rb', line 39 def tag_partial(, title_length) max_length = ViewRecords::Project.max_title_length max_length += ViewRecords::Project.max_depth * 2 if @options[:depth] max_length += 6 if @options[:id] max_length += 2 if @options[:active] spacer = [0, max_length - title_length].max view = " " + ( " " * spacer ) return view + "tags: none" if .length < 1 view += "tags: [" .each { |t| view += "#{t}, "} view[0..-3] + "]" end |
#timerecord_block(record) ⇒ Object
74 75 76 77 78 79 80 81 82 |
# File 'lib/tempo/views/formatters/screen.rb', line 74 def timerecord_block(record) record.format do |r| id = id_partial r.id running = r.running ? "*" : " " description = r.description.empty? ? "#{r.project}" : "#{r.project}: #{r.description}" view = "#{id}#{r.start_time.strftime('%H:%M')} - #{r.end_time.strftime('%H:%M')}#{running} [#{r.duration.format}] #{description}" puts view end end |