Class: Kojak::Printer::Basic

Inherits:
Kojak::Printer show all
Defined in:
lib/kojak/printer/basic.rb

Overview

Internal: Basic printer. It prints stuff to configured output stream.

Direct Known Subclasses

Synchronized

Instance Method Summary collapse

Methods inherited from Kojak::Printer

#puts

Constructor Details

#initialize(out) ⇒ Basic

Public: Constructor. Configures printer to write to given output stream.

out - The Stream to write data to.

Returns nothing.



11
12
13
# File 'lib/kojak/printer/basic.rb', line 11

def initialize(out)
  @out = out
end

Instance Method Details

#write(s, *args) ⇒ Object



15
16
17
18
# File 'lib/kojak/printer/basic.rb', line 15

def write(s, *args)
  args = args.map { |x| JSON.pretty_generate(x) rescue x.inspect }
  @out.write(s.to_s % args)
end