Class: Editeur::Printer

Inherits:
Object
  • Object
show all
Includes:
TTYColor
Defined in:
lib/editeur/printer.rb

Constant Summary collapse

ColorMap =
{
  '+ ' => GREEN,
  '- ' => RED
}

Constants included from TTYColor

TTYColor::GREEN, TTYColor::NORMAL, TTYColor::RED

Class Method Summary collapse

Class Method Details



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/editeur/printer.rb', line 18

def self.print(lines, enable_color = true)
  lines.each { |line|
    if not enable_color
      puts line
    else 
      color = ColorMap[line[0..1]]
      if not color
        raise UnknownFormatError
      end

      puts [color, line, NORMAL].join
    end
  }
end