Class: RubyText::Color
- Inherits:
-
Object
- Object
- RubyText::Color
- Defined in:
- lib/color.rb
Constant Summary collapse
- Colors =
[Black, Blue, Cyan, Green, Magenta, Red, White, Yellow]
Class Method Summary collapse
- .index(color) ⇒ Object
- .pair(fg, bg) ⇒ Object
-
.sym2const(color) ⇒ Object
to curses constant.
Class Method Details
.index(color) ⇒ Object
24 25 26 |
# File 'lib/color.rb', line 24 def self.index(color) Colors.find_index(color) # "our" number end |
.pair(fg, bg) ⇒ Object
28 29 30 31 32 |
# File 'lib/color.rb', line 28 def self.pair(fg, bg) num = 8*index(fg) + index(bg) X.init_pair(num, sym2const(fg), sym2const(bg)) num end |
.sym2const(color) ⇒ Object
to curses constant
20 21 22 |
# File 'lib/color.rb', line 20 def self.sym2const(color) # to curses constant X.const_get("COLOR_#{color.to_s.upcase}") end |