Class: PVN::Log::SummaryFormatter

Inherits:
Formatter show all
Defined in:
lib/pvn/log/formatter/summary_formatter.rb

Constant Summary

Constants inherited from Formatter

Formatter::COLORS, Formatter::WIDTHS

Instance Attribute Summary collapse

Attributes inherited from Formatter

#use_colors

Instance Method Summary collapse

Methods inherited from Formatter

#colors, #width

Methods inherited from ColorFormatter

#add_field, #colorize, #pad

Constructor Details

#initialize(use_colors, entry, idx, from_head, from_tail, total) ⇒ SummaryFormatter

Returns a new instance of SummaryFormatter.



18
19
20
21
22
23
24
25
# File 'lib/pvn/log/formatter/summary_formatter.rb', line 18

def initialize use_colors, entry, idx, from_head, from_tail, total
  super use_colors
  @entry = entry
  @idx = idx
  @from_head = from_head
  @from_tail = from_tail
  @total = total
end

Instance Attribute Details

#entryObject (readonly)

Returns the value of attribute entry.



12
13
14
# File 'lib/pvn/log/formatter/summary_formatter.rb', line 12

def entry
  @entry
end

#from_headObject (readonly)

Returns the value of attribute from_head.



14
15
16
# File 'lib/pvn/log/formatter/summary_formatter.rb', line 14

def from_head
  @from_head
end

#from_tailObject (readonly)

Returns the value of attribute from_tail.



15
16
17
# File 'lib/pvn/log/formatter/summary_formatter.rb', line 15

def from_tail
  @from_tail
end

#idxObject (readonly)

Returns the value of attribute idx.



13
14
15
# File 'lib/pvn/log/formatter/summary_formatter.rb', line 13

def idx
  @idx
end

#totalObject (readonly)

Returns the value of attribute total.



16
17
18
# File 'lib/pvn/log/formatter/summary_formatter.rb', line 16

def total
  @total
end

Instance Method Details

#formatObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/pvn/log/formatter/summary_formatter.rb', line 27

def format
  lines = add_field entry.revision, :revision
  negidx  = (-1 - idx).to_s

  if from_head
    lines << add_field(negidx, :neg_revision)
  else
    lines << pad("", :neg_revision)
  end

  if from_tail
    posidx = "+#{total - idx - 1}"
    lines << add_field(posidx, :pos_revision)
  else
    lines << pad("", :pos_revision)
  end
  
  lines << add_field(entry.author, :author)
  info "entry.date: #{entry.date}"
  info "entry.date.class: #{entry.date.class}"
  dt = DateTime.parse entry.date
  info "dt: #{dt}"
  dfmt = DateFormatter.new.format(entry.date)
  lines << colorize(dfmt, :date)
  lines
end