class Colours::Colours
Constants
- LEADING_PART
#¶ ↑
LEADING_PART
¶ ↑We don’t include the “[” here.
#¶ ↑
- TRAILING_PART
#¶ ↑
TRAILING_PART
¶ ↑#¶ ↑
Public Class Methods
[](i = ARGV)
click to toggle source
Public Instance Methods
+(i = '')
click to toggle source
append(i)
click to toggle source
background(i = :yellow)
click to toggle source
#¶ ↑
background¶ ↑
#¶ ↑
# File lib/colours/class/colours.rb, line 259 def background(i = :yellow) i = i.to_s unless i.start_with? 'background_' i = i.dup if i.frozen? i.prepend('background_') end i = i.to_sym unless HASH_ANSI_COLOURS.has_key? i e 'Warning: the key '+i.to_s+' is not registered in the main Hash.' end i = HASH_ANSI_COLOURS[i].to_s set_use_this_background_colour(i) self end
Also aliased as: bg
bright()
click to toggle source
#¶ ↑
bright¶ ↑
#¶ ↑
# File lib/colours/class/colours.rb, line 251 def bright @internal_hash[:leading_colour_component] = '1' self end
Also aliased as: bold
build_the_main_string()
click to toggle source
#¶ ↑
build_the_main_string
(main tag)¶ ↑
This method must always rebuild the full, modified content.
#¶ ↑
# File lib/colours/class/colours.rb, line 300 def build_the_main_string result = ''.dup result << leading_part? result << '[' result << string_increased_intensity? result << ";#{use_this_colour?}" unless use_this_colour? == '0' if use_this_background_colour? result << ";#{use_this_background_colour?}" end result << ';3' if use_italic? result << ';4' if use_underline? result << ';5' if slow_blink? result << ';7' if reversed? result << 'm' result << raw_content? result << trailing_end? return result end
display()
click to toggle source
#¶ ↑
display¶ ↑
#¶ ↑
# File lib/colours/class/colours.rb, line 188 def display print build_main_string(content?) end
Also aliased as: report
increased_intensity?()
click to toggle source
italic()
click to toggle source
leading_part?()
click to toggle source
raw_content?()
click to toggle source
red()
click to toggle source
#¶ ↑
red¶ ↑
#¶ ↑
# File lib/colours/class/colours.rb, line 324 def red real_name_of_the_method = HASH_ANSI_COLOURS[__callee__] set_use_this_colour(real_name_of_the_method) self end
Also aliased as: blue, black, green, brown, yellow, purple, magenta, cyan, light_blue, light_gray, light_green, light_magenta, white, light_red, grey
reset()
click to toggle source
#¶ ↑
reset (reset tag)¶ ↑
#¶ ↑
# File lib/colours/class/colours.rb, line 64 def reset # ======================================================================= # # === @internal_hash # ======================================================================= # @internal_hash = {} # ======================================================================= # # === :raw_content # ======================================================================= # @internal_hash[:raw_content] = nil # ======================================================================= # # === :leading_colour_component # # This can be '', '0' or '1'. The '1' means bright; the '0' is for # regular colours. The default is ''. # ======================================================================= # @internal_hash[:leading_colour_component] = ''.dup # ======================================================================= # # === :use_italic # ======================================================================= # @internal_hash[:use_italic] = false # ======================================================================= # # === :use_underline # ======================================================================= # @internal_hash[:use_underline] = false # ======================================================================= # # === :slow_blink # ======================================================================= # @internal_hash[:slow_blink] = false # ======================================================================= # # === :use_this_background_colour # ======================================================================= # @internal_hash[:use_this_background_colour] = nil # ======================================================================= # # === :use_this_colour # # We must use a default colour. # ======================================================================= # @internal_hash[:use_this_colour] = '0' # ======================================================================= # # === :reversed # # If this is true then "7" will be used, which will invert foreground # colour and background colour. # ======================================================================= # @internal_hash[:reversed] = false end
reversed()
click to toggle source
reversed?()
click to toggle source
set_content(i)
click to toggle source
set_slow_blink_to_true()
click to toggle source
set_use_this_background_colour(i)
click to toggle source
set_use_this_colour(i)
click to toggle source
set_use_underline_to_true()
click to toggle source
slow_blink()
click to toggle source
slow_blink?()
click to toggle source
string_increased_intensity?()
click to toggle source
trailing_end?()
click to toggle source
underline()
click to toggle source
#¶ ↑
underline¶ ↑
#¶ ↑
# File lib/colours/class/colours.rb, line 224 def underline set_use_underline_to_true self end
Also aliased as: underlined
use_italic?()
click to toggle source
use_this_background_colour?()
click to toggle source
use_this_colour?()
click to toggle source
use_underline?()
click to toggle source