Class: Pixel
- Inherits:
-
Object
- Object
- Pixel
- Defined in:
- lib/roflbalt.rb
Instance Attribute Summary collapse
-
#char ⇒ Object
readonly
Returns the value of attribute char.
Instance Method Summary collapse
- #bg ⇒ Object
- #color_equal?(other) ⇒ Boolean
- #fg ⇒ Object
-
#initialize(char = " ", fg = nil, bg = nil) ⇒ Pixel
constructor
A new instance of Pixel.
- #to_s ⇒ Object
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
#char ⇒ Object (readonly)
Returns the value of attribute char.
102 103 104 |
# File 'lib/roflbalt.rb', line 102 def char @char end |
Instance Method Details
#bg ⇒ Object
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 |
#fg ⇒ Object
103 |
# File 'lib/roflbalt.rb', line 103 def fg; @fg || 255 end |
#to_s ⇒ Object
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 |