Class: JRubySQL::Output::CTerm
- Includes:
- ANSI::Code
- Defined in:
- lib/jrubysql/output/cterm.rb
Constant Summary
Constants inherited from Term
Instance Attribute Summary collapse
-
#colors ⇒ Object
readonly
Returns the value of attribute colors.
Instance Method Summary collapse
- #cursor(empty) ⇒ Object
- #error(message) ⇒ Object
- #info(message) ⇒ Object
-
#initialize(colors) ⇒ CTerm
constructor
A new instance of CTerm.
- #print_cursor(empty) ⇒ Object
- #print_help ⇒ Object
- #result(message) ⇒ Object
- #warn(message) ⇒ Object
- #welcome! ⇒ Object
Methods inherited from Term
Methods included from Messages
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 (readonly)
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 puts wrap(, @ccode[:error]) end |
#info(message) ⇒ Object
52 53 54 |
# File 'lib/jrubysql/output/cterm.rb', line 52 def info puts wrap(, @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 puts wrap(, @ccode[:result]) end |
#warn(message) ⇒ Object
60 61 62 |
# File 'lib/jrubysql/output/cterm.rb', line 60 def warn puts wrap(, @ccode[:warning]) end |