Class: Reviewer::Output::Printer

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

Overview

Wrapper to encapsulate some lower-level details of printing to $stdout

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#streamObject (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



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?

Returns:

  • (Boolean)


28
29
30
# File 'lib/reviewer/output/printer.rb', line 28

def tty?
  stream.tty?
end