Class: Yay::ColourWheel

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

Overview

the colour wheel contains all the constants needed to create coloured text there are also a few static helper methods to make rendering text easier

Constant Summary collapse

MISC =

commands. support varies

{
	:reset       => 0,
	:bright      => 1,
	:dim         => 2,
	:underscore  => 4,
	:blink       => 5,
	:reverse     => 7,
	:hidden      => 8,	

	:normal      => 0, #alias
	:invert      => 7, #alias
	:inverted    => 7, #alias
	:underscored => 4, #alias
}
FG =

foreground colours

{
	:black   => 30,
	:red     => 31,
	:green   => 32,
	:yellow  => 33,
	:blue    => 34,
	:magenta => 35,
	:cyan    => 36,
	:white   => 37,
}
BG =

background colours

{
	:black   => 40,
	:red     => 41,
	:green   => 42,
	:yellow  => 43,
	:blue    => 44,
	:magenta => 45,
	:cyan    => 46,
	:white   => 47
}

Class Method Summary collapse

Class Method Details

.all_namesObject

return all the possible colour names the keys are used as string representations by the parser



48
49
50
51
# File 'lib/yay/colour_wheel.rb', line 48

def self.all_names
	# assume BG and FG have the same keys
	MISC.keys | FG.keys
end

.begin_colours(colour_numbers) ⇒ Object

ge the string that begins the current colour code



54
55
56
# File 'lib/yay/colour_wheel.rb', line 54

def self.begin_colours(colour_numbers)
	"\033[#{colour_numbers.join(';')}m"
end

.end_colourObject

the command necessary to stop printing with colour



59
60
61
# File 'lib/yay/colour_wheel.rb', line 59

def self.end_colour
	"\033[0m"
end

.failObject



68
69
70
# File 'lib/yay/colour_wheel.rb', line 68

def self.fail()
	self.begin_colours([FG[:red]])
end

.successObject

ge the string that begins the current colour code



64
65
66
# File 'lib/yay/colour_wheel.rb', line 64

def self.success
	self.begin_colours([FG[:green]])
end