Class: Snp::Printer

Inherits:
Object
  • Object
show all
Defined in:
lib/snp/cli.rb

Overview

Snp::Printer

This class is responsible for outputing string in normal output and error streams. It defaults to ‘STDOUT` and `STDERR`, respectively but can be used to generate output for other streams.

Example

stream = Snp::Printer.new
stream.out('Hello')  # => 'Hello' is written to the standard output
stream.err('ERROR!') # => 'ERROR!' is written to the standard error

Instance Method Summary collapse

Constructor Details

#initialize(out = STDOUT, err = STDERR) ⇒ Printer

Returns a new instance of Printer.



17
18
19
20
# File 'lib/snp/cli.rb', line 17

def initialize(out = STDOUT, err = STDERR)
  @out = out
  @err = err
end

Instance Method Details

#err(message) ⇒ Object



26
27
28
# File 'lib/snp/cli.rb', line 26

def err(message)
  @err.puts message
end

#out(message) ⇒ Object



22
23
24
# File 'lib/snp/cli.rb', line 22

def out(message)
  @out.puts message
end