Class: XCPretty::Printer

Inherits:
Object
  • Object
show all
Defined in:
lib/xcpretty/printer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Printer

Returns a new instance of Printer.



9
10
11
12
# File 'lib/xcpretty/printer.rb', line 9

def initialize(params)
  klass = params[:formatter]
  @formatter = klass.new(params[:unicode], params[:colorize])
end

Instance Attribute Details

#formatterObject (readonly)

Returns the value of attribute formatter.



7
8
9
# File 'lib/xcpretty/printer.rb', line 7

def formatter
  @formatter
end

Instance Method Details

#finishObject



14
15
16
# File 'lib/xcpretty/printer.rb', line 14

def finish
  @formatter.finish
end

#pretty_print(text) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/xcpretty/printer.rb', line 18

def pretty_print(text)
  formatted_text = formatter.pretty_format(text)
  unless formatted_text.empty?
    STDOUT.print(formatted_text + formatter.optional_newline)
    STDOUT.flush
  end
end