Class: PVN::Log::EntryFormatter

Inherits:
Formatter show all
Defined in:
lib/pvn/log/formatter/entry_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) ⇒ EntryFormatter

Returns a new instance of EntryFormatter.



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

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.



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

def entry
  @entry
end

#from_headObject (readonly)

Returns the value of attribute from_head.



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

def from_head
  @from_head
end

#from_tailObject (readonly)

Returns the value of attribute from_tail.



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

def from_tail
  @from_tail
end

#idxObject (readonly)

Returns the value of attribute idx.



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

def idx
  @idx
end

#totalObject (readonly)

Returns the value of attribute total.



17
18
19
# File 'lib/pvn/log/formatter/entry_formatter.rb', line 17

def total
  @total
end

Instance Method Details

#formatObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/pvn/log/formatter/entry_formatter.rb', line 28

def format
  lines = Array.new
  
  sf = SummaryFormatter.new use_colors, entry, idx, from_head, from_tail, total
  lines << sf.format
  lines << ""
  
  mf = MessageFormatter.new use_colors, entry.message
  lines << mf.format
  lines << ""

  pf = PathFormatter.new use_colors, entry.paths
  lines.concat pf.format
  
  lines
end