Created
February 3, 2012 01:09
-
-
Save ruprict/1726864 to your computer and use it in GitHub Desktop.
ROFLBALT Pixel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Pixel | |
def initialize char = " ", fg = nil, bg = nil | |
@char = char | |
@fg, @bg = fg, bg | |
end | |
attr_reader :char | |
def fg; @fg || 255 end | |
def bg; @bg || 0 end | |
def to_s | |
"\033[48;5;%dm\033[38;5;%dm%s" % [ bg, fg, @char ] | |
end | |
def color_equal? other | |
fg == other.fg && bg == other.bg | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment