Class: PVN::Log::EntriesFormatter

Inherits:
Formatter show all
Defined in:
lib/pvn/log/formatter/entries_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_color, entries, from_head, from_tail) ⇒ EntriesFormatter

Returns a new instance of EntriesFormatter.



14
15
16
17
18
19
# File 'lib/pvn/log/formatter/entries_formatter.rb', line 14

def initialize use_color, entries, from_head, from_tail
  super use_color
  @entries = entries
  @from_head = from_head
  @from_tail = from_tail
end

Instance Attribute Details

#from_headObject (readonly)

Returns the value of attribute from_head.



11
12
13
# File 'lib/pvn/log/formatter/entries_formatter.rb', line 11

def from_head
  @from_head
end

#from_tailObject (readonly)

Returns the value of attribute from_tail.



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

def from_tail
  @from_tail
end

Instance Method Details

#formatObject



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/pvn/log/formatter/entries_formatter.rb', line 21

def format
  lines = Array.new
  total = @entries.size
  @entries.each_with_index do |entry, idx|
    ef = EntryFormatter.new use_colors, entry, idx, from_head, from_tail, total
    lines.concat ef.format
    
    lines << '-' * 55
  end
  lines
end