Class: XCPretty::Printer
- Inherits:
-
Object
- Object
- XCPretty::Printer
- Defined in:
- lib/xcpretty/printer.rb
Instance Attribute Summary collapse
-
#formatter ⇒ Object
readonly
Returns the value of attribute formatter.
Instance Method Summary collapse
- #finish ⇒ Object
-
#initialize(params) ⇒ Printer
constructor
A new instance of Printer.
- #pretty_print(text) ⇒ Object
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
#formatter ⇒ Object (readonly)
Returns the value of attribute formatter.
7 8 9 |
# File 'lib/xcpretty/printer.rb', line 7 def formatter @formatter end |
Instance Method Details
#finish ⇒ Object
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 |