Class: Wassup::Color

Inherits:
Object
  • Object
show all
Defined in:
lib/wassup/color.rb

Defined Under Namespace

Modules: Pair

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(string_name) ⇒ Color

Returns a new instance of Color.



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/wassup/color.rb', line 52

def initialize(string_name)
  @color_pair = case string_name
           when "black"
             Pair::BLACK
           when "blue"
             Pair::BLUE
           when "cyan"
             Pair::CYAN
           when "green"
             Pair::GREEN
           when "magenta"
             Pair::MAGENTA
           when "red"
             Pair::RED
           when "white"
             Pair::WHITE
           when "yellow"
             Pair::YELLOW
           when "gray"
             Pair::GRAY
           else
             if string_name.to_i.to_s == string_name
               string_name.to_i
             else
              Pair::WHITE
             end
           end 
end

Instance Attribute Details

#color_pairObject

Returns the value of attribute color_pair.



5
6
7
# File 'lib/wassup/color.rb', line 5

def color_pair
  @color_pair
end

Class Method Details

.initObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/wassup/color.rb', line 29

def self.init
  Curses.use_default_colors()

  Curses.init_pair(Pair::NORMAL, Pair::WHITE, 0) #white foreground, black background
  Curses.init_pair(Pair::HIGHLIGHT, 0, Pair::WHITE) # black foreground, white background

#      Curses.init_pair(Pair::BORDER, Pair::WHITE, 0) #white foreground, black background
#      Curses.init_pair(Pair::BORDER_FOCUS, Pair::MAGENTA, 0) #white foreground, black background
#
#      Curses.init_pair(Pair::TITLE, Pair::WHITE, 0) #white foreground, black background
#      Curses.init_pair(Pair::TITLE_FOCUS, Pair::WHITE, 0) #white foreground, black background

  Curses.init_pair(Pair::BLACK, Curses::COLOR_BLACK, 0) 
  Curses.init_pair(Pair::BLUE, Curses::COLOR_BLUE, 0) 
  Curses.init_pair(Pair::CYAN, Curses::COLOR_CYAN, 0) 
  Curses.init_pair(Pair::GREEN, Curses::COLOR_GREEN, 0) 
  Curses.init_pair(Pair::MAGENTA, Curses::COLOR_MAGENTA, 0) 
  Curses.init_pair(Pair::RED, Curses::COLOR_RED, 0)
  Curses.init_pair(Pair::WHITE, Pair::WHITE, 0)
  Curses.init_pair(Pair::YELLOW, Curses::COLOR_YELLOW, 0)
  Curses.init_pair(Pair::GRAY, Curses::COLOR_WHITE, 0)
end