Skip to content

Instantly share code, notes, and snippets.

@b1nary b1nary/nixcolor.gemspec
Last active Oct 6, 2015

Embed
What would you like to do?
NixColor - Yet another 255 Ansi colors for ruby gem
Gem::Specification.new do |s|
s.name = 'nixcolor'
s.version = '0.0.2'
s.date = '2012-05-30'
s.summary = "Unix (Ansi) color gem"
s.description = "Yet another 255 Ansi colors for ruby gem"
s.authors = ["Roman Pramberger"]
s.email = '*@gmail.com'
s.files = ["lib/nixcolor.rb"]
s.homepage = 'http://rubygems.org/gems/nixcolor'
end
class NixColor
##
# Generate rgb colors
def self.rgb(red, green, blue)
16 + (red * 36) + (green * 6) + blue
end
##
# set background to color
def self.bg color
"\x1b[48;5;#{color}m"
end
##
# set foreground to color
def self.fg color
"\x1b[38;5;#{color}m"
end
##
# lazy background "shortcut"
def self.background color
self.bg color
end
##
# lazy foreground "shortcut"
def self.foreground color
self.fg color
end
##
# Clear terminal from colors
def self.clear_color
"\x1b[0m"
end
##
# Clear screen and reset cursor
def self.clear
"\e[2J\e[1;1H"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.