Class: Bookwatch::Streams::ColorizedStream

Inherits:
Object
  • Object
show all
Defined in:
lib/bookwatch/streams/colorized_stream.rb

Instance Method Summary collapse

Constructor Details

#initialize(color, stream) ⇒ ColorizedStream

Returns a new instance of ColorizedStream.



6
7
8
9
10
# File 'lib/bookwatch/streams/colorized_stream.rb', line 6

def initialize(color, stream)
  @color = color
  @stream = stream
  @colorizer = Colorizer.new
end

Instance Method Details

#<<(text) ⇒ Object



16
17
18
# File 'lib/bookwatch/streams/colorized_stream.rb', line 16

def <<(text)
  stream << colorizer.colorize(text, color)
end

#puts(line) ⇒ Object



12
13
14
# File 'lib/bookwatch/streams/colorized_stream.rb', line 12

def puts(line)
  stream.puts(colorizer.colorize(line, color))
end