Class: Reviewer::Output::Printer
- Inherits:
-
Object
- Object
- Reviewer::Output::Printer
- Defined in:
- lib/reviewer/output/printer.rb
Overview
Wrapper to encapsulate some lower-level details of printing to $stdout
Instance Attribute Summary collapse
-
#stream ⇒ Object
readonly
Returns the value of attribute stream.
Instance Method Summary collapse
-
#initialize(stream = $stdout) ⇒ Printer
constructor
Creates an instance of Output to print Reviewer activity and results to the console.
- #print(style, content) ⇒ Object
- #puts(style, content) ⇒ Object
- #tty? ⇒ Boolean (also: #style_enabled?)
Constructor Details
#initialize(stream = $stdout) ⇒ Printer
Creates an instance of Output to print Reviewer activity and results to the console
12 13 14 15 16 17 |
# File 'lib/reviewer/output/printer.rb', line 12 def initialize(stream = $stdout) @stream = stream.tap do |str| # If the IO channel supports flushing the output immediately, then ensure it's enabled str.sync = str.respond_to?(:sync=) end end |
Instance Attribute Details
#stream ⇒ Object (readonly)
Returns the value of attribute stream.
9 10 11 |
# File 'lib/reviewer/output/printer.rb', line 9 def stream @stream end |
Instance Method Details
#print(style, content) ⇒ Object
19 20 21 |
# File 'lib/reviewer/output/printer.rb', line 19 def print(style, content) text(style, content) end |
#puts(style, content) ⇒ Object
23 24 25 26 |
# File 'lib/reviewer/output/printer.rb', line 23 def puts(style, content) text(style, content) stream.puts end |
#tty? ⇒ Boolean Also known as: style_enabled?
28 29 30 |
# File 'lib/reviewer/output/printer.rb', line 28 def tty? stream.tty? end |