Class: NixColor

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

Class Method Summary collapse

Class Method Details

.background(color) ⇒ Object

lazy background “shortcut”



22
23
24
# File 'lib/nixcolor.rb', line 22

def self.background color
	self.bg color
end

.bg(color) ⇒ Object

set background to color



10
11
12
# File 'lib/nixcolor.rb', line 10

def self.bg color
	"\x1b[48;5;#{color}m"
end

.clearObject

Clear screen and reset cursor



40
41
42
# File 'lib/nixcolor.rb', line 40

def self.clear
	"\e[2J\e[1;1H"
end

.clear_colorObject

Clear terminal from colors



34
35
36
# File 'lib/nixcolor.rb', line 34

def self.clear_color
	"\x1b[0m"
end

.fg(color) ⇒ Object

set foreground to color



16
17
18
# File 'lib/nixcolor.rb', line 16

def self.fg color
	"\x1b[38;5;#{color}m"
end

.foreground(color) ⇒ Object

lazy foreground “shortcut”



28
29
30
# File 'lib/nixcolor.rb', line 28

def self.foreground color
	self.fg color
end

.rgb(red, green, blue) ⇒ Object

Generate rgb colors



4
5
6
# File 'lib/nixcolor.rb', line 4

def self.rgb(red, green, blue)
	16 + (red * 36) + (green * 6) + blue
end