Module: Console::Terminal

Defined in:
lib/console/terminal/text.rb,
lib/console/terminal/xterm.rb,
lib/console/terminal/logger.rb

Overview

Styled terminal output.

Defined Under Namespace

Classes: Logger, Text, XTerm

Constant Summary collapse

CONSOLE_START_AT =

This, and all related methods, is considered private.

'CONSOLE_START_AT'

Class Method Summary collapse

Class Method Details

.for(io) ⇒ Object


48
49
50
51
52
53
54
# File 'lib/console/terminal/logger.rb', line 48

def self.for(io)
	if io.isatty
		XTerm.new(io)
	else
		Text.new(io)
	end
end

.start_at!(environment = ENV) ⇒ Object

Exports CONSOLE_START which can be used to synchronize the start times of all child processes when they log using delta time.


35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/console/terminal/logger.rb', line 35

def self.start_at!(environment = ENV)
	if time_string = environment[CONSOLE_START_AT]
		start_at = Time.parse(time_string) rescue nil
	end
	
	unless start_at
		start_at = Time.now
		environment[CONSOLE_START_AT] = start_at.to_s
	end
	
	return start_at
end