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



13
14
15
# File 'lib/candy_check/cli/out.rb', line 13

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



9
10
11
# File 'lib/candy_check/cli/out.rb', line 9

def out
  @out
end

Instance Method Details

#pretty(object) ⇒ Object

Pretty print an object to out

Parameters:

  • object (Object)


25
26
27
# File 'lib/candy_check/cli/out.rb', line 25

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

Prints to out

Parameters:

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


19
20
21
# File 'lib/candy_check/cli/out.rb', line 19

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