Class: JRubySQL::Output::CTerm
- Inherits:
-
Term
- Object
- Term
- JRubySQL::Output::CTerm
show all
- Includes:
- ANSI::Code
- Defined in:
- lib/jrubysql/output/cterm.rb
Constant Summary
Constants inherited
from Term
Term::HELP
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Term
#display_mode=, #print_result
Methods included from Messages
#m
Constructor Details
#initialize(colors) ⇒ CTerm
Returns a new instance of CTerm.
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/jrubysql/output/cterm.rb', line 12
def initialize colors
super()
@colors =
YAML.load(
File.read(
File.join(
File.dirname(__FILE__), "color_scheme/default.yml"))).merge(colors || {})
@ccode = @colors.inject(Hash.new('')) { |h, pair|
k, v = pair
h[k.to_sym] = v.strip.split(/\s+/).map { |code| ANSI::Code.send(code) rescue '' }.join
h
}
end
|
Instance Attribute Details
#colors ⇒ Object
Returns the value of attribute colors.
10
11
12
|
# File 'lib/jrubysql/output/cterm.rb', line 10
def colors
@colors
end
|
Instance Method Details
#cursor(empty) ⇒ Object
32
33
34
35
36
37
38
39
40
|
# File 'lib/jrubysql/output/cterm.rb', line 32
def cursor empty
if empty
wrap('jrubysql', @ccode[:prompt1]) +
wrap('> ', @ccode[:prompt2])
else
wrap(' -', @ccode[:prompt3]) +
wrap('> ', @ccode[:prompt4])
end
end
|
#error(message) ⇒ Object
64
65
66
|
# File 'lib/jrubysql/output/cterm.rb', line 64
def error message
puts wrap(message, @ccode[:error])
end
|
#info(message) ⇒ Object
52
53
54
|
# File 'lib/jrubysql/output/cterm.rb', line 52
def info message
puts wrap(message, @ccode[:info])
end
|
#print_cursor(empty) ⇒ Object
42
43
44
|
# File 'lib/jrubysql/output/cterm.rb', line 42
def print_cursor empty
print cursor(empty)
end
|
#print_help ⇒ Object
46
47
48
49
50
|
# File 'lib/jrubysql/output/cterm.rb', line 46
def print_help
puts
puts wrap(HELP, @ccode[:help])
puts
end
|
#result(message) ⇒ Object
56
57
58
|
# File 'lib/jrubysql/output/cterm.rb', line 56
def result message
puts wrap(message, @ccode[:result])
end
|
#warn(message) ⇒ Object
60
61
62
|
# File 'lib/jrubysql/output/cterm.rb', line 60
def warn message
puts wrap(message, @ccode[:warning])
end
|
#welcome! ⇒ Object
28
29
30
|
# File 'lib/jrubysql/output/cterm.rb', line 28
def welcome!
puts bold + JRubySQL.name + reset
end
|