Class: PVN::Log::SummaryFormatter
- Inherits:
-
Formatter
- Object
- ColorFormatter
- Formatter
- PVN::Log::SummaryFormatter
- Defined in:
- lib/pvn/log/formatter/summary_formatter.rb
Constant Summary
Constants inherited from Formatter
Formatter::COLORS, Formatter::WIDTHS
Instance Attribute Summary collapse
-
#entry ⇒ Object
readonly
Returns the value of attribute entry.
-
#from_head ⇒ Object
readonly
Returns the value of attribute from_head.
-
#from_tail ⇒ Object
readonly
Returns the value of attribute from_tail.
-
#idx ⇒ Object
readonly
Returns the value of attribute idx.
-
#total ⇒ Object
readonly
Returns the value of attribute total.
Attributes inherited from Formatter
Instance Method Summary collapse
- #format ⇒ Object
-
#initialize(use_colors, entry, idx, from_head, from_tail, total) ⇒ SummaryFormatter
constructor
A new instance of SummaryFormatter.
Methods inherited from Formatter
Methods inherited from ColorFormatter
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
#entry ⇒ Object (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_head ⇒ Object (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_tail ⇒ Object (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 |
#idx ⇒ Object (readonly)
Returns the value of attribute idx.
13 14 15 |
# File 'lib/pvn/log/formatter/summary_formatter.rb', line 13 def idx @idx end |
#total ⇒ Object (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
#format ⇒ Object
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) 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 |