Class: CandyCheck::CLI::Out

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

Overview

A wrapper to output text information to any kind of buffer

Examples:

out = Out.new(std_buffer)
out.print('something') # => appends 'something' to std_buffer

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(out = $stdout) ⇒ Out

Bind a new out instance to two buffers

Parameters:

  • out (Object) (defaults to: $stdout)

    STDOUT is default



15
16
17
# File 'lib/candy_check/cli/out.rb', line 15

def initialize(out = $stdout)
  @out = out
end

Instance Attribute Details

#outObject (readonly)

Returns buffer used as default outlet.

Returns:

  • (Object)

    buffer used as default outlet



11
12
13
# File 'lib/candy_check/cli/out.rb', line 11

def out
  @out
end

Instance Method Details

#pretty(object) ⇒ Object

Pretty print an object to out

Parameters:

  • object (Object)


27
28
29
# File 'lib/candy_check/cli/out.rb', line 27

def pretty(object)
  PP.pp(object, out)
end

Prints to out

Parameters:

  • text (String) (defaults to: '')


21
22
23
# File 'lib/candy_check/cli/out.rb', line 21

def print(text = '')
  out.puts text
end