Class: Console

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/greenlight/console.rb

Constant Summary collapse

INDENT_STR =
'  '

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConsole

Returns a new instance of Console.



40
41
42
# File 'lib/greenlight/console.rb', line 40

def initialize
	self.indent_level = 0
end

Instance Attribute Details

#indent_levelObject

Returns the value of attribute indent_level.



36
37
38
# File 'lib/greenlight/console.rb', line 36

def indent_level
  @indent_level
end

Class Method Details

.utf8(code) ⇒ Object



72
73
74
# File 'lib/greenlight/console.rb', line 72

def self.utf8(code)
	code.encode('utf-8')
end

Instance Method Details

#action(msg) ⇒ Object



48
49
50
# File 'lib/greenlight/console.rb', line 48

def action(msg)
	puts ' * ' + get_indent + msg
end

#error(msg) ⇒ Object



52
53
54
# File 'lib/greenlight/console.rb', line 52

def error(msg)
	puts Colors.light_red(' ' + Console.utf8("\u2718") + ' ' + get_indent + msg)
end

#get_indentObject



60
61
62
# File 'lib/greenlight/console.rb', line 60

def get_indent
	INDENT_STR * indent_level
end

#indentObject



64
65
66
# File 'lib/greenlight/console.rb', line 64

def indent
	self.indent_level = self.indent_level + 1
end

#info(msg) ⇒ Object



44
45
46
# File 'lib/greenlight/console.rb', line 44

def info(msg)
	puts Colors.grey(' - ' + get_indent + msg)
end

#success(msg) ⇒ Object



56
57
58
# File 'lib/greenlight/console.rb', line 56

def success(msg)
	puts Colors.light_green(' ' + Console.utf8("\u2713") + ' ' + get_indent + msg)
end

#unindentObject



68
69
70
# File 'lib/greenlight/console.rb', line 68

def unindent
	self.indent_level = self.indent_level - 1 unless self.indent_level == 0
end