Class: PVN::Status::Formatter

Inherits:
ColorFormatter show all
Defined in:
lib/pvn/status/formatter/status_formatter.rb

Overview

a format for status entries

Direct Known Subclasses

EntriesFormatter, EntryFormatter

Constant Summary collapse

COLORS =
{
  :added        => [ :green ],
  :modified     => [ :yellow ],
  :deleted      => [ :red ],
  :renamed      => [ :magenta ],
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from ColorFormatter

#add_field, #colorize, #pad

Constructor Details

#initialize(use_colors) ⇒ Formatter

Returns a new instance of Formatter.



22
23
24
25
# File 'lib/pvn/status/formatter/status_formatter.rb', line 22

def initialize use_colors
  # should also turn this off if not on a terminal that supports colors ...
  @use_colors = use_colors
end

Instance Attribute Details

#use_colorsObject (readonly)

Returns the value of attribute use_colors.



20
21
22
# File 'lib/pvn/status/formatter/status_formatter.rb', line 20

def use_colors
  @use_colors
end

Instance Method Details

#colors(field) ⇒ Object



27
28
29
# File 'lib/pvn/status/formatter/status_formatter.rb', line 27

def colors field
  use_colors ? COLORS[field] : nil
end