Class: Pixel

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(char = " ", fg = nil, bg = nil) ⇒ Pixel



98
99
100
101
# File 'lib/roflbalt.rb', line 98

def initialize char = " ", fg = nil, bg = nil
  @char = char
  @fg, @bg = fg, bg
end

Instance Attribute Details

#charObject (readonly)

Returns the value of attribute char.



102
103
104
# File 'lib/roflbalt.rb', line 102

def char
  @char
end

Instance Method Details

#bgObject



104
# File 'lib/roflbalt.rb', line 104

def bg; @bg || 0 end

#color_equal?(other) ⇒ Boolean



108
109
110
# File 'lib/roflbalt.rb', line 108

def color_equal? other
  fg == other.fg && bg == other.bg
end

#fgObject



103
# File 'lib/roflbalt.rb', line 103

def fg; @fg || 255 end

#to_sObject



105
106
107
# File 'lib/roflbalt.rb', line 105

def to_s
  "\033[48;5;%dm\033[38;5;%dm%s" % [ bg, fg, @char ]
end