Module: Console::Output

Defined in:
lib/console/output.rb,
lib/console/output/null.rb,
lib/console/output/split.rb,
lib/console/output/default.rb,
lib/console/output/failure.rb,
lib/console/output/wrapper.rb,
lib/console/output/terminal.rb,
lib/console/output/sensitive.rb,
lib/console/output/serialized.rb

Overview

Output handling.

Defined Under Namespace

Modules: Default, Text, XTerm Classes: Failure, Null, Sensitive, Serialized, Split, Terminal, Wrapper

Constant Summary collapse

JSON =
Deprecated.

This is a legacy constant, please use ‘Serialized` instead.

Serialized

Class Method Summary collapse

Class Method Details

.new(output = nil, env = ENV, **options) ⇒ Object

Create a new output based on the environment.

The environment variable ‘CONSOLE_OUTPUT` can be used to specify a list of output classes to wrap around the output. If not specified the Default output is used.

The output argument is deliberately unders-specified but can be an IO object or an instance of Console::Output.



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/console/output.rb', line 24

def self.new(output = nil, env = ENV, **options)
	if names = env["CONSOLE_OUTPUT"]
		names = names.split(",").reverse
		
		names.inject(output) do |output, name|
			Output.const_get(name).new(output, **options)
		end
	else
		return Output::Default.new(output, **options)
	end
end