module Colours

#

require ‘colours/256_colours/support_for_256_colours.rb’

#
#

require ‘colours/autogenerated/support_for_256_colours.rb’

#
#

require ‘colours/autogenerated/support_for_html_colours.rb’

#
#

This file contains the code that will call the corresponding colour method depending on which colour-mode the user prefers.

#

require ‘colours/autogenerated/toplevel_basic_colour_methods.rb’

#
#

This is a “dummy” class from which you can quickly subclass if you need methods such as royalblue() to work in your class.

#

require ‘colours/base/base.rb’ class Foobar < Colours::Base

#
#

Note that the primary ANSI colours are:

black, red, green, yellow, blue, magenta, cyan, white
#

require ‘colours/basic_colours/basic_colours.rb’ include ::Colours::BasicColours

#
#

Colours::Colours

The ANSII colours are:

Black       0;30     Dark Gray     1;30
Red         0;31     Light Red     1;31
Green       0;32     Light Green   1;32
Brown       0;33     Yellow        1;33
Blue        0;34     Light Blue    1;34
Purple      0;35     Light Purple  1;35
Cyan        0;36     Light Cyan    1;36
Light Gray  0;37     White         1;37

This list is for colours at the console. In xterm, the code 1;31 is not “Light Red” but “Bold Red”.

Usage example:

Colours::Colours.new(ARGV)
#

require ‘colours/class/colours.rb’ Colours.fancy_parse<red>E. coli</red>

#
#

require ‘colours/colour_methods/colour_methods.rb’

#
#

require ‘colours/colour_table/colour_table.rb’

#
#

require ‘colours/commandline/commandline.rb’

#
#

require ‘colours/commandline/menu.rb’

#

frozen_string_literal = true

#

require ‘colours/constants/escape.rb’

#
#

require ‘colours/constants/file_constants.rb’ Colours.file_html_colours_to_rgb?

#
#

require ‘colours/constants/hash_ansi_colours.rb’

#

frozen_string_literal = true

#

require ‘colours/constants/hash_simple_colours.rb’

#

frozen_string_literal = true

#

This file primarily stores constants, including AnsiColours-related escape sequences. Additionally it will also store methods can refer or make use of these constants, such as Colours.teal(), and so forth.

The different escape sequences can be combined into a single escape sequence by separating them via semicolons. For example, to create a section of text that is bold text with a yellow foreground and blue background, the escape sequence would be:

^[[1;33;44m

Keep in mind that in bash the ESC code can be either of the following:

\e
\033 (octal)
\x1B (hexadecimal)

BOLD colour constants will have a “1” as part of their escape sequence. Note that the bold colours are sometimes also called the “bright colours”.

#

To see which colours are supported/supportable, for each terminal, have a look at this link:

https://misc.flogisoft.com/bash/tip_colors_and_formatting#terminals_compatibility

This wikipedia link is also somewhat useful for ANSI escape sequences in general:

http://en.wikipedia.org/wiki/ANSI_escape_code#Colors
#

This file is tested in the file colours/test/testing_the_basic_colours_of_the_colours_project.rb

#

The following table shows the colour-codes for the terminal:

Black       0;30   Dark Gray     1;30
Red         0;31   Light Red     1;31
Green       0;32   Light Green   1;32
Yellow      0;33   Brown         1;33
Blue        0;34   Light Blue    1;34
Magenta     0;35   Light Magenta 1;35
Cyan        0;36   Light Cyan    1;36
Light Gray  0;37   White         1;37

These are also stored in the Hash called HASH_SIMPLE_COLOURS.

#

require ‘colours/constants/misc.rb’

#
#

require ‘colours/constants/newline.rb’

#
#

require ‘colours/constants/registered_colour_methods.rb’

#
#

Colours::E

#

require ‘colours/e/e.rb’ include ::Colours::E

#
#

require ‘colours/eparse/eparse.rb’

#
#

This file will add the autogenerated HTML-colours onto the toplevel module “namespace”.

#

require ‘colours/html_colours/add_html_colours_onto_the_toplevel_namespace.rb’ Colours.add_html_colours_onto_the_toplevel_namespace

#
#

require ‘colours/html_colours/html_colours.rb’

#
#

require ‘colours/kde_colour_palette/kde_colour_palette.rb’

#
#

require ‘colours/map_symbol_to_corresponding_colour/map_symbol_to_corresponding_colour.rb’

#
#

require ‘colours/module.rb’

#
#

require ‘colours/project/project.rb’

#
#
#

require ‘paint_detected_mode.rb’

#
#
#

require ‘colours/rainbow_colours/report_errors.rb’

#
#

require ‘colours/rainbow_colours/set_mode.rb’

#
#

The “colour-methods” are methods such as sdir(), swarn() and so forth.

The file here specifies code that can be used to require these .rb files from the given colour_methods/ subdirectory of the colours project.

#

require ‘colours/requires/require_the_colour_methods.rb’

#
#

Colours::RGB

The Colours::RBG class was used to convert from RGB values to hex format. However had these days it is not as widely used anymore within the colours project.

Code in this .rb file here in general can be used for RGB-related functionality. A good example for what can be done with this is to convert a HTML colour, such as “slateblue”, into its RGB representation.

#

require ‘colours/rgb/rgb.rb’

#
#

Add the test() method to the Colours module here.

#

require ‘colours/testing/testing.rb’

#
#

This file contains code that can be used to autogenerate ruby code, and store this into a .rb file. That functionality is mostly useful on my home system, though.

#

require ‘colours/toplevel_methods/autogenerate.rb’

#
#

require ‘colours/toplevel_methods/bold.rb’ Colours.bold

#
#

require ‘colours/toplevel_methods/bold_and_italic.rb’

#
#

require ‘colours/toplevel_methods/cat.rb’

#
#

require ‘colours/toplevel_methods/clear_screen.rb’

#
#

require ‘colours/toplevel_methods/cliner.rb’

#
#

require ‘colours/toplevel_methods/col.rb’

#
#

require ‘colours/toplevel_methods/e.rb’

#
#

require ‘colours/toplevel_methods/esystem.rb’

#
#

require ‘colours/toplevel_methods/html_colour_to_hex_value.rb’

#
#

require ‘colours/toplevel_methods/html_colourize.rb’

#
#

require ‘colours/toplevel_methods/is_on_roebe.rb’

#
#

require ‘colours/toplevel_methods/italic.rb’

#
#

require ‘colours/toplevel_methods/make_colour.rb’

#
#

This file will hold code that relates to the html-colours, such as “steelblue” or “royalblue” and so forth.

#

require ‘colours/toplevel_methods/methods_related_to_html_colours.rb’ Colours.html_colour_to_hex_value(ARGV)

#
#

require ‘colours/toplevel_methods/misc.rb’

#
#

require ‘colours/toplevel_methods/open_this_file.rb’

#
#

require ‘colours/toplevel_methods/prefer_this_colour_schemata.rb’

#
#

require ‘colours/toplevel_methods/random_value.rb’

#
#

require ‘colours/toplevel_methods/remove_escape_sequence.rb’ Colours.remove_escape_sequence

#

frozen_string_literal = true

#

require ‘colours/toplevel_methods/revert.rb’

#
#

require ‘colours/toplevel_methods/set_last_colour_used.rb’

#

frozen_string_literal = true

#

require ‘colours/toplevel_methods/show_basic_colour_palette.rb’

#
#

This file will handline underline-functionality in a terminal. It supports basic colours and the HTML colours.

#

require ‘colours/toplevel_methods/underline.rb’ Colours.return_underline

#
#

require ‘colours/toplevel_methods/use_colours.rb’

#
#

require ‘colours/version/version.rb’

#

Constants

ALL_COLOURS
#

ALL_COLOURS

Simply combine the two Arrays, MAIN_COLOURS and SECONDARY_COLOURS, into one aggregate Array.

#
ARRAY_REGISTERED_ANSI_COLOURS

ARRAY_REGISTERED_ANSI_COLOURS

This array exists mostly for testing-purposes.

#
BBLUE
BGREEN
BLACK
BLACK_ON_WHITE_BACKGROUND
#

Colours::BLACK_ON_WHITE_BACKGROUND

Usage example:

puts Colours::BLACK_ON_WHITE_BACKGROUND+'Hello world!'+Colours::RESET
#
BLACK_ON_WHITE_BG
BLUE
BOLDBLUE
BOLDRED
BOLDYELLOW
BOLD_BLACK
BOLD_BLUE
BOLD_BROWN
BOLD_CYAN
BOLD_GREEN
BOLD_RED
BOLD_TEAL
BOLD_WHITE
BOLD_YELLOW
BRED
BRIGHT_BLACK
BRIGHT_BLUE
BRIGHT_BROWN
BRIGHT_CYAN
BRIGHT_GREEN
BRIGHT_MAGENTA
BRIGHT_PINK
BRIGHT_RED
BRIGHT_TEAL
BRIGHT_WHITE
BRIGHT_YELLOW
BROWN
BWHITE
BYEL
BYELLOW
CGREEN
CGREY
CLEAR
CLOSING_TAG
COLOUR_BLACK
#

COLOUR_BLACK

#
COLOUR_BLUE
#

COLOUR_BLUE

#
COLOUR_BOLD_BLUE
COLOUR_BOLD_GREEN
COLOUR_BOLD_RED
COLOUR_BOLD_TEAL
COLOUR_BOLD_WHITE
COLOUR_BOLD_YELLOW
COLOUR_BROWN
#

COLOUR_BROWN

#
COLOUR_CYAN
#

COLOUR_CYAN

This is also called TEAL, sort of.

#
COLOUR_DARK_GRAY
#

COLOUR_DARK_GRAY

This is also called “black bold”.

#
COLOUR_GRAY
COLOUR_GREEN
#

COLOUR_GREEN

#
COLOUR_LIGHT_BLUE
#

COLOUR_LIGHT_BLUE

This is also known as “bold blue”.

#
COLOUR_LIGHT_CYAN
#

COLOUR_LIGHT_CYAN

#
COLOUR_LIGHT_GRAY
#

COLOUR_LIGHT_GRAY

This is also known as white.

#
COLOUR_LIGHT_GREEN
#

COLOUR_LIGHT_GREEN

#
COLOUR_LIGHT_GREY
COLOUR_LIGHT_MAGENTA
#

COLOUR_LIGHT_MAGENTA

This is not the “normal” magenta, but the light variant; also called light purple.

#
COLOUR_LIGHT_PURPLE
COLOUR_LIGHT_RED
#

COLOUR_LIGHT_RED

#
COLOUR_MAGENTA
#

COLOUR_MAGENTA

#
COLOUR_NC
#

Colours::COLOUR_NC

Note that this will actually reset all attributes.

The “e[0m” sequence removes all attributes, including formatting and colours. It may be useful to add it to the end of each colour text - and this is what the Colours project is essentially doing.

An alternative may be to assign REVERT to WHITE, but this seems to be incorrect according to the specification.

#
COLOUR_PINK
COLOUR_PURPLE
COLOUR_RED
#

COLOUR_RED (red tag)

#
COLOUR_RESET
COLOUR_TEAL
COLOUR_WHITE
#

COLOUR_WHITE

This is bold white, actually.

#
COLOUR_YELLOW
#

COLOUR_YELLOW

#
CRED
CYAN
CYANB
DARKGREEN
DEFAULT_COLOUR
DEFAULT_TEXT
#

Colours::DEFAULT_TEXT

#
ESC
#

Colours::ESC

Escape sequences start with the character ESC (ASCII decimal 27/hex 0x1B/octal 033).

The characters ESC and [ (left bracket) are called CSI, for “Control Sequence Initiator”.

Keep in mind that “e” can be represented via “u001b” in Ruby, too.

#
FILE_256_COLOURS
#

Colours::FILE_256_COLOURS

#
FILE_BASIC_COLOURS
#

Colours::FILE_BASIC_COLOURS

#
FILE_HTML_COLOURS
#

Colours::FILE_HTML_COLOURS

#
FILE_KDE_COLOUR_PALETTE
#

Colours::FILE_KDE_COLOUR_PALETTE

#
FILE_PREFER_THIS_COLOUR_SCHEMATA
#

Colours::FILE_PREFER_THIS_COLOUR_SCHEMATA

#
FILE_USE_THESE_VALUES_FOR_THE_COLOUR_METHODS
#

Colours::FILE_USE_THESE_VALUES_FOR_THE_COLOUR_METHODS

#
GENERIC_RUBY_HEADER
#

GENERIC_RUBY_HEADER

#
GOLD
GRAY
GREEN
GREY
HASH_ANSI_COLOURS
#

HASH_ANSI_COLOURS

#
HASH_NEW_COLOURS
#

HASH_NEW_COLOURS

This is the new hash, which we can transition-into when necessary.

It is only rarely used these days, though (as of the year 2018).

If you want to use these colours, you can use this simpler API:

Colourss.set_method_to_colour_table :new_colours
#
HASH_SIMPLE_COLOURS
#

Colours::HASH_SIMPLE_COLOURS

This hash will only store one name for the corresponding colour code.

#
HOME_DIRECTORY_OF_USER_X
#

HOME_DIRECTORY_OF_USER_X

This constant is only useful on my home system.

#
IS_A_TEST
#

Colours::IS_A_TEST

#
ITALIC_CODE
#

ITALIC_CODE

If you wish to test italic output quickly on the terminal, then you can use something like this:

echo -e "\e[3mone two three\e[23m"
#
KDE_COLOUR_PALETTE
LAST_UPDATE
#

LAST_UPDATE

#
LEFT
#

LEFT

Leading on the left side, for RGB value setting. This is the beginning of a special instruction. Note that “e[38” should be equal to “x1b”, but IRB reports that this is not the case so.

Examples on the www show usage such as this:

printf "\x1b[${bg};2;${red};${green};${blue}m\n"
printf "\x1b[38;2;255;100;0mTRUECOLOR\x1b[0m\n"
#
LIGHTBLUE
LIGHTGREEN
LIGHT_BLUE
LIGHT_PURPLE
LIGHT_RED
MAGENTA
MAIN_COLOURS
#

Colours::MAIN_COLOURS

The main colours come next.

Eight main colours are currently defined, according to:

http://en.wikipedia.org/wiki/ANSI_escape_code#Colors

The range is:

Intensity:     0    1    2      3     4      5      6    7
Normal:     Black  Red Green Yellow  Blue  Magenta Cyan White

Yellow, in my opinion, looks more like brown.

#
N
#

N

#
PINK
PROJECT_BASE_DIRECTORY
#

Colours::PROJECT_BASE_DIRECTORY

#
PURPLE
RED
REDB
REDRAW_THE_PROMPT
#

REDRAW_THE_PROMPT

The following constant is necessary in order for the background colour to apply to the whole line and in order for the foreground colour to apply to the cursor.

#
REGEX_FOR_HTML_COLOURS
#

REGEX_FOR_HTML_COLOURS

This regex supports the use case where we can match against HTML colours. (The name is a bit of a misnomer, though.)

For the following regex, see this entry at rubular:

https://rubular.com/r/o5r4DneMTGOsbX
#
REGEX_REMOVE_ANSI_ESCAPE_CHARACTERS
#

REGEX_REMOVE_ANSI_ESCAPE_CHARACTERS

This regex can be used to get rid of (some) AnsiEscape characters.

#
REGISTERED_COLOUR_METHODS
#

Colours::REGISTERED_COLOUR_METHODS

These methods constitute the registered colour methods.

These have a corresponding method, such as snormal() or sdir() or sfile().

snormal() stands for the “normal” colour, aka the “default colour”.

#
REGISTERED_COLOUR_METHODS_ALIASES
#

Colours::REGISTERED_COLOUR_METHODS_ALIASES

This Array should hold all aliases to the main colour-methods, such as simportant() or sargument().

#
REMOVE_ANSI_ESCAPE_CHARACTERS
RESET
RESET_ALL_ATTRIBUTES
#

RESET_ALL_ATTRIBUTES

This is essentially the same as COLOUR_NC / RESET.

#
RESET_TERMINAL
REV
REVERT
SECONDARY_COLOURS
#

Colours::SECONDARY_COLOURS

The secondary Colours.

Colours which are not part of the MAIN_COLOURS Array.

The secondary colours are:

Bright Black
Bright Red
Bright Green
Bright Yellow
Bright Blue
Bright Magenta
Bright Cyan
Bright White
#
TEAL
TEST_FILE
#

Colours::TEST_FILE

#
UNDERLINE_CODE
#

UNDERLINE_CODE

To quickly test the underline-functionality, you can try:

echo -e "\e[4mone two three\e[23m"
#
URL_TO_THE_DOCUMENTATION
#

URL_TO_THE_DOCUMENTATION

#
USE_THIS_COLOUR_FOR_THE_DEFAULT_COLOUR
#

USE_THIS_COLOUR_FOR_THE_DEFAULT_COLOUR

Here we specify the default colour to be used, in order to revert to the prior colour in use. This can be modified by the user, in order to conform to other colours if said user wishes to do so.

#
VERSION
#

VERSION

#
WHITE
YEL
YELLOW

Public Class Methods

add_html_colours_onto_the_toplevel_namespace() click to toggle source
#

Colours.add_html_colours_onto_the_toplevel_namespace

#
# File lib/colours/html_colours/add_html_colours_onto_the_toplevel_namespace.rb, line 18
def self.add_html_colours_onto_the_toplevel_namespace
  extend Colours::SupportForHTMLColours
end
autogenerate_the_module_for_the_256_colours() click to toggle source
#

Colours.autogenerate_the_module_for_the_256_colours

This method will autogenerate the module that will support the 256 colours.

#
# File lib/colours/toplevel_methods/autogenerate.rb, line 188
  def self.autogenerate_the_module_for_the_256_colours
    _ = ''.dup
    _ << GENERIC_RUBY_HEADER+"
# require 'colours/autogenerated/support_for_256_colours.rb'
# =========================================================================== #
"
    _ << "module Colours\n\n"
    _ << "module SupportFor256Colours # include Colours::SupportFor256Colours\n\n".dup
    _ << "  require 'colours/256_colours/support_for_256_colours.rb'\n\n"
    comment_line = '  # '+('='*73)+' #'+N
    @dataset_for_the_256_colours.each {|name_of_the_colour, id|
      use_this_name = name_of_the_colour.downcase
      _ << comment_line
      _ << '  # === Colours::SupportFor256Colours.'+use_this_name+N
      _ << comment_line
      _ << "  def self.#{use_this_name}(i = '')#{N}"
      _ << "    if Colours.use_colours?\n"
      _ << "      return Colours.return_this_256_colour(__method__, i)\n"
      _ << "    else\n"
      _ << "      return i\n"
      _ << "    end\n"
      _ << "  end; def #{use_this_name}(i = ''); SupportFor256Colours.#{use_this_name}(i); end#{N}#{N}"
    }
    _ << 'end; end'
    what = _
    # ======================================================================= #
    # This is only useful on my home system really:
    # ======================================================================= #
    into = HOME_DIRECTORY_OF_USER_X+'programming/ruby/src/'\
           'colours/lib/colours/autogenerated/support_for_256_colours.rb'
    puts 'Storing into:'
    puts
    puts '  '+into
    puts
    require 'save_file'
    SaveFile.write_what_into(what, into)
  end
autogenerate_the_module_for_the_html_colours( into = HOME_DIRECTORY_OF_USER_X+'programming/ruby/src/'\ 'colours/lib/colours/autogenerated/support_for_html_colours.rb' ) click to toggle source
#

Colours.autogenerate_the_module_for_the_html_colours

This method will autogenerate the module that will support the html colours.

#
# File lib/colours/toplevel_methods/autogenerate.rb, line 34
  def self.autogenerate_the_module_for_the_html_colours(
      into = HOME_DIRECTORY_OF_USER_X+'programming/ruby/src/'\
             'colours/lib/colours/autogenerated/support_for_html_colours.rb'
    )
    _ = ''.dup
    _ << GENERIC_RUBY_HEADER+"
# require 'colours/autogenerated/support_for_html_colours.rb'
# =========================================================================== #
"
    _ << "module Colours\n\n"
    _ << "module SupportForHTMLColours # include Colours::SupportForHTMLColours\n\n".dup
    _ << "  require 'colours/toplevel_methods/html_colourize.rb'\n"
    _ << "  require 'colours/toplevel_methods/use_colours.rb'\n\n"
    comment_line = '  # '+('='*73)+' #'+N
    available_html_colours?.each {|name_of_the_html_colour|
      _ << comment_line
      _ << '  # === Colours::SupportForHTMLColours.'+name_of_the_html_colour+N
      _ << comment_line
      _ << "  def self.#{name_of_the_html_colour}(i = '', &block)\n"
      _ << "    if ::Colours.use_html_colours?\n"
      _ << "      return ::Colours.html_colourize(__method__, i, &block)\n"
      _ << "    else\n"
      _ << "      return i\n"
      _ << "    end\n"
      _ << "  end; def #{name_of_the_html_colour}(i = '', &block); SupportForHTMLColours.#{name_of_the_html_colour}(i, &block); end#{N}"
      # ===================================================================== #
      # Next, due to several reasons, we add a prepended "konsole_colour_"
      # as name to this method.
      # ===================================================================== #
      _ << "       def konsole_colour_#{name_of_the_html_colour}(i = '', &block); SupportForHTMLColours.#{name_of_the_html_colour}(i, &block); end#{N}#{N}"
    }
    _ << 'end; end'
    what = _
    # ======================================================================= #
    # This is only useful on my home system really:
    # ======================================================================= #
    puts 'Storing into:'
    puts
    puts '  '+into
    puts
    require 'save_file'
    SaveFile.write_what_into(what, into)
  end
autogenerate_toplevel_basic_colour_methods( into = HOME_DIRECTORY_OF_USER_X+'programming/ruby/src/'\ 'colours/lib/colours/autogenerated/toplevel_basic_colour_methods.rb' ) click to toggle source
#

Colours.autogenerate_toplevel_basic_colour_methods

The code in this method will autogenerate the toplevel colour methods, such as Colours.yellow().

The code needs to respect several settings. For example, whether colours are used or not. Additionally, for methods such as Colours.yellow(), we need to find out whether we use the basic colours, the 256-colours or the HTML colours, and call the corresponding method in these cases.

#
# File lib/colours/toplevel_methods/autogenerate.rb, line 89
  def self.autogenerate_toplevel_basic_colour_methods(
      into = HOME_DIRECTORY_OF_USER_X+'programming/ruby/src/'\
             'colours/lib/colours/autogenerated/toplevel_basic_colour_methods.rb'
    )
    comment_line = "  # ======================================================================== \n"
    store_this_string = ''.dup
    header = <<-EOF
#{GENERIC_RUBY_HEADER}
# This file contains the code that will call the corresponding colour method
# depending on which colour-mode the user prefers.
# =========================================================================== #
# require 'colours/autogenerated/toplevel_basic_colour_methods.rb'
# =========================================================================== #
module Colours

require 'colours/toplevel_methods/use_colours.rb'
require 'colours/basic_colours/basic_colours.rb'
require 'colours/256_colours/support_for_256_colours.rb'
require 'colours/autogenerated/support_for_html_colours.rb'

module AllColourMethods # include Colours::AllColourMethods

EOF

    store_this_string << header
    # ======================================================================= #
    # First define the methods for the basic colours:
    # ======================================================================= #
    array = return_a_unique_array_containing_all_available_colours
    array.each {|this_basic_colour| # <- e. g. "yellow".
      this_basic_colour = this_basic_colour.dup
      if this_basic_colour.include?(' ') and
         array.include?(this_basic_colour.delete(' '))
        # =================================================================== #
        # === This must be an alias
        #
        # In this case we will also add an alias containing the '_' part.
        # We will only add this as an alias for include-actions, though.
        # (This may change at a later point in the future - not sure yet.)
        # =================================================================== #
        store_this_string << "       def #{this_basic_colour.tr(' ','_')}(i = ''); AllColourMethods.#{this_basic_colour.delete(' ')}(i); end\n"
      else
        name_of_the_method = this_basic_colour.downcase.delete(' ').dup
        store_this_string << comment_line
        store_this_string << "  # === Colours::AllColourMethods.#{name_of_the_method}\n"
        store_this_string << comment_line
        store_this_string << "  def self.#{name_of_the_method}(i = '', &block)\n"
        store_this_string << "    if ::Colours.use_colours?\n"
        # =================================================================== #
        # Ok, so we determine what to do with this colour-method:
        # =================================================================== #
        store_this_string << "      if ::Colours.is_this_a_html_colour?(__method__)\n"
        store_this_string << "        return ::Colours::SupportForHTMLColours.#{name_of_the_method}(i, &block)\n"
        store_this_string << "      elsif ::Colours.is_this_a_256_colour?(__method__)\n"
        store_this_string << "        return ::Colours::SupportFor256Colours.#{name_of_the_method}(i, &block)\n"
        store_this_string << "      else\n"
        store_this_string << "        return ::Colours::BasicColours.#{name_of_the_method}(i, &block)\n"
        store_this_string << "      end\n"
        store_this_string << "    else\n"
        store_this_string << "      return i\n"
        store_this_string << "    end\n"
        store_this_string << "  end; def #{name_of_the_method}(i = '', &block); AllColourMethods.#{name_of_the_method}(i, &block); end\n"
        # =================================================================== #
        # Next, due to several reasons, we add a prepended "konsole_colour_"
        # as name to this method.
        # =================================================================== #
        store_this_string << "       def konsole_colour_#{name_of_the_method}(i = ''); AllColourMethods.#{name_of_the_method}(i); end\n"
        store_this_string << "       def konsole_#{name_of_the_method}(i = ''); AllColourMethods.#{name_of_the_method}(i); end\n"
        store_this_string << "       self.instance_eval { alias konsole_colour_#{name_of_the_method} #{name_of_the_method} } # === Colours::AllColourMethods.konsole_colour_#{name_of_the_method}\n"
        store_this_string << "       def Colours.e#{name_of_the_method}(i = ''); puts AllColourMethods.#{name_of_the_method}(i); end\n"
        store_this_string << "       def e#{name_of_the_method}(i = ''); puts AllColourMethods.#{name_of_the_method}(i); end\n"
        store_this_string << "       alias ekonsole_colour_#{name_of_the_method} e#{name_of_the_method}\n"
        store_this_string << "\n"
      end
    }
    store_this_string << "end; end\n"
    what = store_this_string .dup
    # ======================================================================= #
    # This is only useful on my home system really:
    # ======================================================================= #
    puts 'Storing into the file:'
    puts
    puts "  #{into}"
    puts
    File.delete(into) if File.exist? into # Get rid of the old file.
    begin
      require 'save_file'
      SaveFile.write_what_into(what, into)
    rescue LoadError
      puts 'save_file gem is not available/installed.'
    end
  end
available_file_constants() click to toggle source
#

Colours.available_file_constants

#
# File lib/colours/constants/file_constants.rb, line 61
def self.available_file_constants
  [
    FILE_HTML_COLOURS,
    FILE_KDE_COLOUR_PALETTE
  ]
end
available_html_colours?() click to toggle source
#

Colours.available_html_colours?

#
# File lib/colours/html_colours/html_colours.rb, line 300
def self.available_html_colours?
  ::Colours::HtmlColours.available_html_colours?
end
available_main_colours?() click to toggle source
#

Colours.available_main_colours?

Feedback which main colours are available.

#
# File lib/colours/constants/hash_simple_colours.rb, line 61
def self.available_main_colours?
  MAIN_COLOURS
end
bold( show_this_text = 'This must be bold.' ) click to toggle source
#

Colours.bold

ANSI colour escape code for bold is “1”.

The method has to call Colours.rev() at the end, because that way downstream users can modify the default rev-colour in use.

Usage example:

puts ' ok | '+Colours.bold('Hello world!')+' | ok'
#
# File lib/colours/toplevel_methods/bold.rb, line 25
def self.bold(
    show_this_text = 'This must be bold.'
  )
  return "\x1b[1m#{show_this_text}#{::Colours.rev}"
end
bold_and_italic( i = 'This must be bold.' ) click to toggle source
#

Colours.bold_and_italic

Usage example:

puts Colours.bold_and_italic 'Hello world!'
#
# File lib/colours/toplevel_methods/bold_and_italic.rb, line 21
def self.bold_and_italic(
    i = 'This must be bold.'
  )
  if i.is_a? Array
    i = i.join(' ')
  end
  italic(bold(i))
end
cat( file_descriptor, hash_options = {} ) click to toggle source
#

Colours.cat

The first argument may be ARGF. It ought to respond to .each anyway.

Note that .cat() will delegate towards print_line().

#
# File lib/colours/toplevel_methods/cat.rb, line 18
def self.cat(
    file_descriptor, hash_options = {}
  )
  print "\e[?25l" if hash_options[:animate] # Print this if we animate (enabling psychedelics).
  # ======================================================================= #
  # Iterate over the file_descriptor passed.
  # ======================================================================= #
  file_descriptor.each { |line|
    hash_options[:os] += 1 # Increase the output-count.
    # ===================================================================== #
    # Next, colourize the line. This depends on the method called
    # print_rainbow_line().
    # ===================================================================== #
    RainbowColours.print_rainbow_line(
      line, hash_options
    ) # Delegate towards print_line.
  }
ensure
  print "\e[?25h" if hash_options[:animate]
end
clear_screen() click to toggle source
#

Colours.clear_screen

Simply perform ‘clear’ here.

#
# File lib/colours/toplevel_methods/clear_screen.rb, line 14
def self.clear_screen
  system 'clear'
end
cliner(i = 78) { || ... } click to toggle source
#

Colours.cliner

#
# File lib/colours/toplevel_methods/cliner.rb, line 12
def self.cliner(i = 78, &block)
  yield if block_given?
  puts '=' * i
end
col( i, optional_arg_not_in_use_right_now = '' ) click to toggle source
#

Colours.col (col tag)

Careful - this method may collide with other methods named col().

Usage examples:

Colours.col '/Depot/j/geojgirjh'
Colours.col '/Users/x/AUDIO/'
Colours.col '/Users/x/AUDIO/Westbam_Sunshine.mp3'
#
# File lib/colours/toplevel_methods/col.rb, line 23
def self.col(
    i,
    optional_arg_not_in_use_right_now = ''
  )
  if File.exist? i
    ftype = File.ftype(i)
    # e 'The ftype is: '+ftype # <- This could be used for debugging.
    case ftype
    # ===================================================================== #
    # === file
    # ===================================================================== #
    when 'file'
      return sfile(i)
    # ===================================================================== #
    # === directory
    # ===================================================================== #
    when 'directory'
      return sdir(i)
    # ===================================================================== #
    # === link
    # ===================================================================== #
    when 'link'
      return ssymlink(i)
    else
      e "module Colours: We do not know the filetype `#{ftype}`"
    end
  else # Else return the input a bit changed.
    return sfile(i) # We modify it because that is better.
  end
end
colour_method_or_display_the_content_of_the_file_or_use_via_pipe( i = ARGF, name_of_the_colour = $PROGRAM_NAME ) click to toggle source
#

Colours.colour_method_or_display_the_content_of_the_file_or_use_via_pipe

This method has an awful name, but its core use case is simple.

It will handle commandline instructions such as:

orange Hey there
slateblue how are you doing?

Usage example from within ruby:

Colours.testing123('abc', :orange)
#
# File lib/colours/toplevel_methods/misc.rb, line 29
def self.colour_method_or_display_the_content_of_the_file_or_use_via_pipe(
    i                  = ARGF,
    name_of_the_colour = $PROGRAM_NAME
  )
  require 'colours/autogenerated/support_for_html_colours.rb'
  # ======================================================================= #
  # === :read
  # ======================================================================= #
  if i.respond_to? :read
    i = i.read
  elsif i and File.exist?(i)
    i = File.read(i)
  end
  i = Colours.remove_trailing_end_from(i)
  if i.is_a? Array
    i = i.join(' ').strip
  end
  if name_of_the_colour
    if name_of_the_colour.respond_to?(:include?) and
       name_of_the_colour.include?('/')
      name_of_the_colour = File.basename(name_of_the_colour)
    end
  end
  name_of_the_colour = name_of_the_colour.to_sym
  return ::Colours::SupportForHTMLColours.send(name_of_the_colour, i)
end
colour_table?() click to toggle source
#

Colours.colour_table?

This method will feedback the available colour-table.

To invoke this method, try the following code:

pp Colours.colours?
#
# File lib/colours/colour_table/colour_table.rb, line 269
def self.colour_table?
  @colour_table
end
colour_to_rgb(i = :slateblue) click to toggle source
#

Colours.colour_to_rgb

#
# File lib/colours/html_colours/html_colours.rb, line 293
def self.colour_to_rgb(i = :slateblue)
  ::Colours::HtmlColours.colour_to_rgb(i)
end
commandline?() click to toggle source
#

Colours.commandline?

#
# File lib/colours/commandline/commandline.rb, line 24
def self.commandline?
  @commandline
end
convert_hex_code_to_RGBA_array( i, default_alpha_value = 1.0 ) click to toggle source
#

Colours.convert_hex_code_to_RGBA_array

RGBA stands for “red, green, blue, alpha”. Alpha indicates how opaque each pixel is.

The usual values for the alpha parameter, aka the last parameter, is a number between 0.0 (which means “fully transparent”) and the number 1.0 (which means “not transparent at all”).

Note that this method is similar to Colours.convert_hex_to_rgb(hex), but it has a fourth argument, aka A (for Alpha), on top of the RGB values.

Usage example:

Colours.convert_hex_code_to_RGBA_array('#baf185') # => [186, 241, 133]
#
# File lib/colours/toplevel_methods/misc.rb, line 191
def self.convert_hex_code_to_RGBA_array(
    i, default_alpha_value = 1.0
  )
  rgba_array = convert_hex_to_rgb(i)
  rgba_array << default_alpha_value
  return rgba_array
end
convert_hex_to_rgb(hex) click to toggle source
#

Colours.convert_hex_to_rgb

This method will convert e. g. baf185 to [186, 241, 133]. Thus it will return an Array, denoting the R, G, B values.

How to do this conversion on your own?

(1) Get the 2 left digits of the hex color code and convert
    to decimal value to get the red color level.
(2) Get the 2 middle digits of the hex color code and
    convert to decimal value to get the green color level.
(3) Get the 2 right digits of the hex color code and
    convert to decimal value to get the blue color level.

Usage example:

Colours.convert_hex_to_rgb('#baf185') # => [186, 241, 133]
#
# File lib/colours/toplevel_methods/misc.rb, line 158
def self.convert_hex_to_rgb(hex)
  if hex.is_a? Array
    hex = hex.first
  end
  hex = hex.to_s.dup
  hex.delete!('#') if hex.include? '#'
  array = [] # We will return this Array.
  r = hex[0,2].to_i(16)
  g = hex[2,2].to_i(16)
  b = hex[4,2].to_i(16)
  array << r << g << b
  return array
end
convert_this_html_colour_into_an_array_of_rgb_values( html_colour = :random ) click to toggle source
#

Colours.convert_this_html_colour_into_an_array_of_rgb_values

This method will take a String as input, a HTML colour such as ‘slateblue’, and proceed to return an Array containing three entries (R, G, B) as its value.

For RGB colours we specify the code like this:

38;2;$R;$G;$B

Thus:

\e[38;2;R;G;Bm
#
# File lib/colours/rgb/rgb.rb, line 265
def self.convert_this_html_colour_into_an_array_of_rgb_values(
    html_colour = :random
  )
  case html_colour
  when :random
    html_colour = return_random_html_colour
  end
  if ::Colours.include_this_html_colour? html_colour
    pointer = ::Colours.hash_html_colours?[html_colour.to_s] # <- Must be an input-String.
    [ pointer[0], pointer[1], pointer[2] ] # <- Build the Array here.
  else # else it is not included
    nil
  end
end
convert_this_rgb_value_into_a_html_colour(i, g = nil, b = nil) click to toggle source
#

Colours.convert_this_rgb_value_into_a_html_colour

This method will convert a given RGB value (input assumed to be an Array) into the corresponding HTML colour.

Note that the first input argument, called ‘i`, can also be read as R (aka red). So the whole input line becomes “r, g, b”, which makes this quite trivial to remember.

#
# File lib/colours/rgb/rgb.rb, line 236
def self.convert_this_rgb_value_into_a_html_colour(i, g = nil, b = nil)
  if i.is_a?(Numeric) and g and b
    i = [i, g, b] # Re-compose the given input in this case, as only one Array was provided.
  end
  _ = ::Colours.hash_html_colours?
  possible_matches = _.select {|key, inner_array|
    (i[0] == inner_array[0]) and
    (i[1] == inner_array[1]) and
    (i[2] == inner_array[2])
  }
  possible_matches.keys.first
end
convert_this_rgb_value_to_that_hexadecimal_representation( r, g = nil, b = nil ) click to toggle source
#

Colours.convert_this_rgb_value_to_that_hexadecimal_representation

This method will convert RGB values to their hexadecimal (hex) representation.

Invocation example:

Colours.convert_this_rgb_value_to_that_hexadecimal_representation([240, 248, 255]) # => "F0F8FF"
Colours.rgb_to_hex(255,0,0) # => "FF0000"
Colours.rgb_to_hex('255255255')
Colours.rgb_to_hex(:slateblue)
#
# File lib/colours/rgb/rgb.rb, line 416
def self.convert_this_rgb_value_to_that_hexadecimal_representation(
    r, g = nil, b = nil
  )
  hash = ::Colours.hash_html_colours?
  if r.is_a?(Symbol) and g.nil? and b.nil? and
     is_this_a_html_colour?(r)
    return hash[r.to_s][3]
  end
  if r.is_a?(String) and !r.include?('#') and g.nil? and b.nil?
    # ======================================================================= #
    # In this case assume input such as '255255255'
    # ======================================================================= #
    splitted = r.split(/(...)/).reject(&:empty?)
    r, g, b = splitted
  end
  if r.is_a?(Array) and (r.size > 1) and g.nil? and b.nil?
    # ======================================================================= #
    # In this case the user supplied only a single Array as input.
    # ======================================================================= #
    this_html_colour = ::Colours.convert_this_rgb_value_into_a_html_colour(r)
  else
    this_html_colour = ::Colours.convert_this_rgb_value_into_a_html_colour(r, g, b)
  end
  if this_html_colour
    hash[this_html_colour][3]
  else
    nil
  end
end
default_colour( i = '', make_newline = false ) click to toggle source
#

Colours.default_colour

Invocation example:

puts Colours.default_colour('Hello world!')
#
# File lib/colours/colour_methods/colour_methods.rb, line 65
def self.default_colour(
    i            = '',
    make_newline = false
  )
  if @use_colours
    if make_newline
      i = "#{i}#{N}"
    end
    if @use_html_colours
      i = SupportForHTMLColours.send(@colour_table[__method__.to_sym], i)
    elsif @use_256_colours
      use_this_colour = map_this_symbol_to_that_256_colour(@colour_table[__method__.to_sym])  
      i = SupportFor256Colours.send(use_this_colour, i)
    else
      i = "#{corresponding_colour?(@colour_table[__method__.to_sym])}"\
          "#{i}"\
          "#{rev}"
    end
  end
  return i
end
disable_colours( be_verbose = false ) click to toggle source
#

Colours.disable_colours

This method can be used to disable the colours on the Colours namespace.

#
# File lib/colours/toplevel_methods/use_colours.rb, line 74
def self.disable_colours(
    be_verbose = false
  )
  puts 'Disabling colours next.' if be_verbose
  @use_colours = false
end
disable_html_colours() click to toggle source
#

Colours.disable_html_colours

Disable the HTML colours.

#
# File lib/colours/toplevel_methods/use_colours.rb, line 64
def self.disable_html_colours
  @use_html_colours = false
end
display_this_256_colour( id = 9, use_this_text = "Hello world!\n" ) { || ... } click to toggle source
#

Colours.display_this_256_colour

The first argument should be a number from 0 to 255.

You can also batch-output all colours, by using something like:

Colours.display_this_256_colour('0-255',"Hello world, in a batch!\n")

Generic usage example:

Colours.display_this_256_colour(33, 'yo there') { :newline }
#
# File lib/colours/256_colours/support_for_256_colours.rb, line 98
def self.display_this_256_colour(
    id            = 9,
    use_this_text = "Hello world!\n",
    &block
  )
  if block_given?
    yielded = yield
    case yielded
    when :newline
      use_this_text = use_this_text.dup if use_this_text.frozen?
      use_this_text << "\n"
    end
  end
  if id.is_a?(String) and id.include?('-')
    # ===================================================================== #
    # Assume pseudo-range input.
    # ===================================================================== #
    splitted = id.split('-')
    range = (splitted.first.to_i .. splitted.last.to_i).to_a
    range.each {|this_range_id|
      display_this_256_colour(this_range_id, use_this_text, &block)
    }
  else
    print return_this_256_colour(id, use_this_text)
  end
end
does_include?(i = :slateblue) click to toggle source
#

Colours.does_include?

Usage examples:

Colours.does_include? 'slateblue'
Colours.is_this_html_colour_included? 'royalblue' # => true
Colours.is_this_html_colour_included? 'megawhite' # => false
#
# File lib/colours/html_colours/html_colours.rb, line 327
def self.does_include?(i = :slateblue)
  i = i.to_sym unless i.is_a? Symbol
  ::Colours::HtmlColours.does_include?(i)
end
does_this_line_include_a_html_colour?( line ) click to toggle source
#

Colours.does_this_line_include_a_html_colour?

This method can be used to determine whether the given input-string contains a valid HTML colour or whether it does not.

Returns: a boolean.

Invocation examples:

Colours.does_this_line_include_a_html_colour? "<green>yo there</green> <orange>getline() function</orange>" # => true
Colours.does_this_line_include_a_html_colour? "foo bar" # => false
#
# File lib/colours/toplevel_methods/misc.rb, line 130
def self.does_this_line_include_a_html_colour?(
    line
  )
  html_colours?.any? {|entry|
    line.include? entry
  }
end
does_this_string_include_a_html_colour?(i) click to toggle source
#

Colours.does_this_string_include_a_html_colour?

#
# File lib/colours/toplevel_methods/methods_related_to_html_colours.rb, line 247
def self.does_this_string_include_a_html_colour?(i)
  result = (i =~ REGEX_FOR_HTML_COLOURS)
  result = false if result.nil?
  result
end
does_this_string_include_a_html_number?(i) click to toggle source
#

Colours.does_this_string_include_a_html_number?

This method will return true if the string includes tags such as <one> or <two> and so forth.

#
# File lib/colours/toplevel_methods/methods_related_to_html_colours.rb, line 259
def self.does_this_string_include_a_html_number?(i)
  i.include?('<one>')   or
  i.include?('<two>')   or
  i.include?('<three>') or
  i.include?('<four>')  or
  i.include?('<five>')
end
e( i = N, append_newline = true ) click to toggle source
#

Colours.e

This is essentially just a fancified wrapper over puts.

Usage examples:

Colours.e 'hello world'
Colours.e "hi \n there\n is everything fine? \n\n"
#
# File lib/colours/toplevel_methods/e.rb, line 33
def self.e(
    i              = N,
    append_newline = true
  )
  i = i.join(' ') if i.is_a? Array
  _ = "#{rev}#{i.to_s.dup}".dup # Work with a copy here.
  _.chomp! # So that we won't have more than one newline initially.
  _ << N if append_newline # This should be the last modification before calling print.
  print _ # And print the result finally.
end
ealiceblue(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 38
def Colours.ealiceblue(i = ''); puts AllColourMethods.aliceblue(i); end
eantiquewhite(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 61
def Colours.eantiquewhite(i = ''); puts AllColourMethods.antiquewhite(i); end
eaqua(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 84
def Colours.eaqua(i = ''); puts AllColourMethods.aqua(i); end
eaquamarine(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 107
def Colours.eaquamarine(i = ''); puts AllColourMethods.aquamarine(i); end
eaquamarine1(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 130
def Colours.eaquamarine1(i = ''); puts AllColourMethods.aquamarine1(i); end
eaquamarine3(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 153
def Colours.eaquamarine3(i = ''); puts AllColourMethods.aquamarine3(i); end
eazure(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 176
def Colours.eazure(i = ''); puts AllColourMethods.azure(i); end
ebeige(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 199
def Colours.ebeige(i = ''); puts AllColourMethods.beige(i); end
ebisque(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 222
def Colours.ebisque(i = ''); puts AllColourMethods.bisque(i); end
eblack(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 245
def Colours.eblack(i = ''); puts AllColourMethods.black(i); end
eblanchedalmond(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 268
def Colours.eblanchedalmond(i = ''); puts AllColourMethods.blanchedalmond(i); end
eblue(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 291
def Colours.eblue(i = ''); puts AllColourMethods.blue(i); end
eblue1(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 314
def Colours.eblue1(i = ''); puts AllColourMethods.blue1(i); end
eblue3(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 337
def Colours.eblue3(i = ''); puts AllColourMethods.blue3(i); end
eblueviolet(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 360
def Colours.eblueviolet(i = ''); puts AllColourMethods.blueviolet(i); end
ebrown(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 383
def Colours.ebrown(i = ''); puts AllColourMethods.brown(i); end
eburlywood(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 406
def Colours.eburlywood(i = ''); puts AllColourMethods.burlywood(i); end
ecadetblue(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 429
def Colours.ecadetblue(i = ''); puts AllColourMethods.cadetblue(i); end
echartreuse(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 452
def Colours.echartreuse(i = ''); puts AllColourMethods.chartreuse(i); end
echartreuse1(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 475
def Colours.echartreuse1(i = ''); puts AllColourMethods.chartreuse1(i); end
echartreuse2(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 498
def Colours.echartreuse2(i = ''); puts AllColourMethods.chartreuse2(i); end
echartreuse3(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 521
def Colours.echartreuse3(i = ''); puts AllColourMethods.chartreuse3(i); end
echartreuse4(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 544
def Colours.echartreuse4(i = ''); puts AllColourMethods.chartreuse4(i); end
echocolate(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 567
def Colours.echocolate(i = ''); puts AllColourMethods.chocolate(i); end
ecomment( i, optional_split_at_this_character = ' click to toggle source
#

Colours.ecomment

This method was added on Nov 2013.

In April 2014, the ability to split at any arbitrary character was added, which can be controlled via the second argument given to that method. By default it will split on the token ‘#’.

#
# File lib/colours/colour_methods/colour_methods.rb, line 23
def self.ecomment(
    i,
    optional_split_at_this_character = '#', # ← Specify which character to split at.
    first_colour_to_use         = :steelblue,
    second_colour_to_use        = :seagreen,
    colour_to_use_for_the_token = :slategray
  )
  _ = i.to_s
  if optional_split_at_this_character.is_a? Hash
    # ===================================================================== #
    # === :token
    # ===================================================================== #
    if optional_split_at_this_character.has_key? :token
      optional_split_at_this_character = optional_split_at_this_character.delete :token
    end
  end
  optional_split_at_this_character = optional_split_at_this_character.to_s
  # ======================================================================= #
  # === If we can find a token to split at
  # ======================================================================= #
  if _.include? optional_split_at_this_character
    _ = _.dup if _.frozen?
    splitted = _.split(optional_split_at_this_character)
    first_part  = ::Colours::SupportForHTMLColours.send(first_colour_to_use, splitted.first)
    middle_part = ::Colours::SupportForHTMLColours.send(colour_to_use_for_the_token, optional_split_at_this_character)
    second_part = ::Colours::SupportForHTMLColours.send(second_colour_to_use, splitted.last)
    _ = first_part+
        middle_part+
        second_part+
        ::Colours.rev
  end
  e _
end
ecoral(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 590
def Colours.ecoral(i = ''); puts AllColourMethods.coral(i); end
ecornflowerblue(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 613
def Colours.ecornflowerblue(i = ''); puts AllColourMethods.cornflowerblue(i); end
ecornsilk(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 636
def Colours.ecornsilk(i = ''); puts AllColourMethods.cornsilk(i); end
ecornsilk1(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 659
def Colours.ecornsilk1(i = ''); puts AllColourMethods.cornsilk1(i); end
ecrimson(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 682
def Colours.ecrimson(i = ''); puts AllColourMethods.crimson(i); end
ecyan(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 705
def Colours.ecyan(i = ''); puts AllColourMethods.cyan(i); end
ecyan1(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 728
def Colours.ecyan1(i = ''); puts AllColourMethods.cyan1(i); end
ecyan2(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 751
def Colours.ecyan2(i = ''); puts AllColourMethods.cyan2(i); end
ecyan3(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 774
def Colours.ecyan3(i = ''); puts AllColourMethods.cyan3(i); end
edarkblue(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 798
def Colours.edarkblue(i = ''); puts AllColourMethods.darkblue(i); end
edarkcyan(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 821
def Colours.edarkcyan(i = ''); puts AllColourMethods.darkcyan(i); end
edarkgoldenrod(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 844
def Colours.edarkgoldenrod(i = ''); puts AllColourMethods.darkgoldenrod(i); end
edarkgray(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 867
def Colours.edarkgray(i = ''); puts AllColourMethods.darkgray(i); end
edarkgreen(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 890
def Colours.edarkgreen(i = ''); puts AllColourMethods.darkgreen(i); end
edarkgrey(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 913
def Colours.edarkgrey(i = ''); puts AllColourMethods.darkgrey(i); end
edarkkhaki(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 936
def Colours.edarkkhaki(i = ''); puts AllColourMethods.darkkhaki(i); end
edarkmagenta(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 959
def Colours.edarkmagenta(i = ''); puts AllColourMethods.darkmagenta(i); end
edarkolivegreen(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 982
def Colours.edarkolivegreen(i = ''); puts AllColourMethods.darkolivegreen(i); end
edarkolivegreen1(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 1005
def Colours.edarkolivegreen1(i = ''); puts AllColourMethods.darkolivegreen1(i); end
edarkolivegreen2(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 1028
def Colours.edarkolivegreen2(i = ''); puts AllColourMethods.darkolivegreen2(i); end
edarkolivegreen3(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 1051
def Colours.edarkolivegreen3(i = ''); puts AllColourMethods.darkolivegreen3(i); end
edarkorange(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 1074
def Colours.edarkorange(i = ''); puts AllColourMethods.darkorange(i); end
edarkorange3(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 1097
def Colours.edarkorange3(i = ''); puts AllColourMethods.darkorange3(i); end
edarkorchid(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 1120
def Colours.edarkorchid(i = ''); puts AllColourMethods.darkorchid(i); end
edarkred(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 1143
def Colours.edarkred(i = ''); puts AllColourMethods.darkred(i); end
edarksalmon(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 1166
def Colours.edarksalmon(i = ''); puts AllColourMethods.darksalmon(i); end
edarkseagreen(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 1189
def Colours.edarkseagreen(i = ''); puts AllColourMethods.darkseagreen(i); end
edarkseagreen1(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 1212
def Colours.edarkseagreen1(i = ''); puts AllColourMethods.darkseagreen1(i); end
edarkseagreen2(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 1235
def Colours.edarkseagreen2(i = ''); puts AllColourMethods.darkseagreen2(i); end
edarkseagreen3(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 1258
def Colours.edarkseagreen3(i = ''); puts AllColourMethods.darkseagreen3(i); end
edarkseagreen4(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 1281
def Colours.edarkseagreen4(i = ''); puts AllColourMethods.darkseagreen4(i); end
edarkslateblue(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 1304
def Colours.edarkslateblue(i = ''); puts AllColourMethods.darkslateblue(i); end
edarkslategray(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 1327
def Colours.edarkslategray(i = ''); puts AllColourMethods.darkslategray(i); end
edarkslategray1(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 1350
def Colours.edarkslategray1(i = ''); puts AllColourMethods.darkslategray1(i); end
edarkslategray2(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 1373
def Colours.edarkslategray2(i = ''); puts AllColourMethods.darkslategray2(i); end
edarkslategray3(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 1396
def Colours.edarkslategray3(i = ''); puts AllColourMethods.darkslategray3(i); end
edarkslategrey(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 1419
def Colours.edarkslategrey(i = ''); puts AllColourMethods.darkslategrey(i); end
edarkturquoise(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 1442
def Colours.edarkturquoise(i = ''); puts AllColourMethods.darkturquoise(i); end
edarkviolet(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 1465
def Colours.edarkviolet(i = ''); puts AllColourMethods.darkviolet(i); end
edeeppink(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 1488
def Colours.edeeppink(i = ''); puts AllColourMethods.deeppink(i); end
edeeppink1(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 1511
def Colours.edeeppink1(i = ''); puts AllColourMethods.deeppink1(i); end
edeeppink2(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 1534
def Colours.edeeppink2(i = ''); puts AllColourMethods.deeppink2(i); end
edeeppink3(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 1557
def Colours.edeeppink3(i = ''); puts AllColourMethods.deeppink3(i); end
edeeppink4(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 1580
def Colours.edeeppink4(i = ''); puts AllColourMethods.deeppink4(i); end
edeepskyblue(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 1603
def Colours.edeepskyblue(i = ''); puts AllColourMethods.deepskyblue(i); end
edeepskyblue1(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 1626
def Colours.edeepskyblue1(i = ''); puts AllColourMethods.deepskyblue1(i); end
edeepskyblue2(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 1649
def Colours.edeepskyblue2(i = ''); puts AllColourMethods.deepskyblue2(i); end
edeepskyblue3(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 1672
def Colours.edeepskyblue3(i = ''); puts AllColourMethods.deepskyblue3(i); end
edeepskyblue4(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 1695
def Colours.edeepskyblue4(i = ''); puts AllColourMethods.deepskyblue4(i); end
edimgray(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 1718
def Colours.edimgray(i = ''); puts AllColourMethods.dimgray(i); end
edimgrey(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 1741
def Colours.edimgrey(i = ''); puts AllColourMethods.dimgrey(i); end
edodgerblue(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 1764
def Colours.edodgerblue(i = ''); puts AllColourMethods.dodgerblue(i); end
edodgerblue1(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 1787
def Colours.edodgerblue1(i = ''); puts AllColourMethods.dodgerblue1(i); end
edodgerblue2(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 1810
def Colours.edodgerblue2(i = ''); puts AllColourMethods.dodgerblue2(i); end
edodgerblue3(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 1833
def Colours.edodgerblue3(i = ''); puts AllColourMethods.dodgerblue3(i); end
efancy( i = '', make_newline = false ) click to toggle source
#

Colours.efancy

This simply will output the result from sfancy(), defined above.

#
# File lib/colours/colour_methods/colour_methods.rb, line 555
def self.efancy(
    i            = '',
    make_newline = false
  )
  e sfancy(i, make_newline)
end
efirebrick(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 1856
def Colours.efirebrick(i = ''); puts AllColourMethods.firebrick(i); end
efloralwhite(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 1879
def Colours.efloralwhite(i = ''); puts AllColourMethods.floralwhite(i); end
eforestgreen(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 1902
def Colours.eforestgreen(i = ''); puts AllColourMethods.forestgreen(i); end
efuchsia(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 1925
def Colours.efuchsia(i = ''); puts AllColourMethods.fuchsia(i); end
egainsboro(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 1948
def Colours.egainsboro(i = ''); puts AllColourMethods.gainsboro(i); end
eghostwhite(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 1971
def Colours.eghostwhite(i = ''); puts AllColourMethods.ghostwhite(i); end
egold(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 1994
def Colours.egold(i = ''); puts AllColourMethods.gold(i); end
egold1(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 2017
def Colours.egold1(i = ''); puts AllColourMethods.gold1(i); end
egold3(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 2040
def Colours.egold3(i = ''); puts AllColourMethods.gold3(i); end
egoldenrod(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 2063
def Colours.egoldenrod(i = ''); puts AllColourMethods.goldenrod(i); end
egray(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 2086
def Colours.egray(i = ''); puts AllColourMethods.gray(i); end
egreen(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 2109
def Colours.egreen(i = ''); puts AllColourMethods.green(i); end
egreen1(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 2132
def Colours.egreen1(i = ''); puts AllColourMethods.green1(i); end
egreen3(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 2155
def Colours.egreen3(i = ''); puts AllColourMethods.green3(i); end
egreen4(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 2178
def Colours.egreen4(i = ''); puts AllColourMethods.green4(i); end
egreenyellow(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 2201
def Colours.egreenyellow(i = ''); puts AllColourMethods.greenyellow(i); end
egrey(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 2224
def Colours.egrey(i = ''); puts AllColourMethods.grey(i); end
egrey0(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 2247
def Colours.egrey0(i = ''); puts AllColourMethods.grey0(i); end
egrey100(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 2270
def Colours.egrey100(i = ''); puts AllColourMethods.grey100(i); end
egrey11(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 2293
def Colours.egrey11(i = ''); puts AllColourMethods.grey11(i); end
egrey15(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 2316
def Colours.egrey15(i = ''); puts AllColourMethods.grey15(i); end
egrey19(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 2339
def Colours.egrey19(i = ''); puts AllColourMethods.grey19(i); end
egrey23(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 2362
def Colours.egrey23(i = ''); puts AllColourMethods.grey23(i); end
egrey27(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 2385
def Colours.egrey27(i = ''); puts AllColourMethods.grey27(i); end
egrey3(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 2408
def Colours.egrey3(i = ''); puts AllColourMethods.grey3(i); end
egrey30(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 2431
def Colours.egrey30(i = ''); puts AllColourMethods.grey30(i); end
egrey35(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 2454
def Colours.egrey35(i = ''); puts AllColourMethods.grey35(i); end
egrey37(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 2477
def Colours.egrey37(i = ''); puts AllColourMethods.grey37(i); end
egrey39(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 2500
def Colours.egrey39(i = ''); puts AllColourMethods.grey39(i); end
egrey42(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 2523
def Colours.egrey42(i = ''); puts AllColourMethods.grey42(i); end
egrey46(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 2546
def Colours.egrey46(i = ''); puts AllColourMethods.grey46(i); end
egrey50(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 2569
def Colours.egrey50(i = ''); puts AllColourMethods.grey50(i); end
egrey53(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 2592
def Colours.egrey53(i = ''); puts AllColourMethods.grey53(i); end
egrey54(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 2615
def Colours.egrey54(i = ''); puts AllColourMethods.grey54(i); end
egrey58(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 2638
def Colours.egrey58(i = ''); puts AllColourMethods.grey58(i); end
egrey62(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 2661
def Colours.egrey62(i = ''); puts AllColourMethods.grey62(i); end
egrey63(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 2684
def Colours.egrey63(i = ''); puts AllColourMethods.grey63(i); end
egrey66(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 2707
def Colours.egrey66(i = ''); puts AllColourMethods.grey66(i); end
egrey69(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 2730
def Colours.egrey69(i = ''); puts AllColourMethods.grey69(i); end
egrey7(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 2753
def Colours.egrey7(i = ''); puts AllColourMethods.grey7(i); end
egrey70(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 2776
def Colours.egrey70(i = ''); puts AllColourMethods.grey70(i); end
egrey74(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 2799
def Colours.egrey74(i = ''); puts AllColourMethods.grey74(i); end
egrey78(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 2822
def Colours.egrey78(i = ''); puts AllColourMethods.grey78(i); end
egrey82(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 2845
def Colours.egrey82(i = ''); puts AllColourMethods.grey82(i); end
egrey84(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 2868
def Colours.egrey84(i = ''); puts AllColourMethods.grey84(i); end
egrey85(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 2891
def Colours.egrey85(i = ''); puts AllColourMethods.grey85(i); end
egrey89(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 2914
def Colours.egrey89(i = ''); puts AllColourMethods.grey89(i); end
egrey93(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 2937
def Colours.egrey93(i = ''); puts AllColourMethods.grey93(i); end
ehoneydew(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 2960
def Colours.ehoneydew(i = ''); puts AllColourMethods.honeydew(i); end
ehoneydew2(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 2983
def Colours.ehoneydew2(i = ''); puts AllColourMethods.honeydew2(i); end
ehotpink(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 3006
def Colours.ehotpink(i = ''); puts AllColourMethods.hotpink(i); end
ehotpink2(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 3029
def Colours.ehotpink2(i = ''); puts AllColourMethods.hotpink2(i); end
ehotpink3(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 3052
def Colours.ehotpink3(i = ''); puts AllColourMethods.hotpink3(i); end
eimp( i = '', make_newline = false ) click to toggle source
#

Colours.eimp

#
# File lib/colours/colour_methods/colour_methods.rb, line 359
def self.eimp(
    i            = '',
    make_newline = false
  )
  e simp(i, make_newline)
end
eindianred(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 3075
def Colours.eindianred(i = ''); puts AllColourMethods.indianred(i); end
eindianred1(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 3098
def Colours.eindianred1(i = ''); puts AllColourMethods.indianred1(i); end
eindigo(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 3121
def Colours.eindigo(i = ''); puts AllColourMethods.indigo(i); end
eivory(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 3144
def Colours.eivory(i = ''); puts AllColourMethods.ivory(i); end
ekhaki(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 3167
def Colours.ekhaki(i = ''); puts AllColourMethods.khaki(i); end
ekhaki1(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 3190
def Colours.ekhaki1(i = ''); puts AllColourMethods.khaki1(i); end
ekhaki3(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 3213
def Colours.ekhaki3(i = ''); puts AllColourMethods.khaki3(i); end
elavender(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 3236
def Colours.elavender(i = ''); puts AllColourMethods.lavender(i); end
elavenderblush(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 3259
def Colours.elavenderblush(i = ''); puts AllColourMethods.lavenderblush(i); end
elawngreen(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 3282
def Colours.elawngreen(i = ''); puts AllColourMethods.lawngreen(i); end
elemonchiffon(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 3305
def Colours.elemonchiffon(i = ''); puts AllColourMethods.lemonchiffon(i); end
elightblue(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 3378
def Colours.elightblue(i = ''); puts AllColourMethods.lightblue(i); end
elightcoral(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 3401
def Colours.elightcoral(i = ''); puts AllColourMethods.lightcoral(i); end
elightcyan(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 3424
def Colours.elightcyan(i = ''); puts AllColourMethods.lightcyan(i); end
elightcyan1(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 3447
def Colours.elightcyan1(i = ''); puts AllColourMethods.lightcyan1(i); end
elightcyan3(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 3470
def Colours.elightcyan3(i = ''); puts AllColourMethods.lightcyan3(i); end
elightgoldenrod1(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 3493
def Colours.elightgoldenrod1(i = ''); puts AllColourMethods.lightgoldenrod1(i); end
elightgoldenrod2(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 3516
def Colours.elightgoldenrod2(i = ''); puts AllColourMethods.lightgoldenrod2(i); end
elightgoldenrod3(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 3539
def Colours.elightgoldenrod3(i = ''); puts AllColourMethods.lightgoldenrod3(i); end
elightgoldenrodyellow(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 3562
def Colours.elightgoldenrodyellow(i = ''); puts AllColourMethods.lightgoldenrodyellow(i); end
elightgray(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 3585
def Colours.elightgray(i = ''); puts AllColourMethods.lightgray(i); end
elightgreen(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 3608
def Colours.elightgreen(i = ''); puts AllColourMethods.lightgreen(i); end
elightgrey(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 3631
def Colours.elightgrey(i = ''); puts AllColourMethods.lightgrey(i); end
elightmagenta(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 3332
def Colours.elightmagenta(i = ''); puts AllColourMethods.lightmagenta(i); end
elightpink(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 3654
def Colours.elightpink(i = ''); puts AllColourMethods.lightpink(i); end
elightpink1(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 3677
def Colours.elightpink1(i = ''); puts AllColourMethods.lightpink1(i); end
elightpink3(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 3700
def Colours.elightpink3(i = ''); puts AllColourMethods.lightpink3(i); end
elightpink4(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 3723
def Colours.elightpink4(i = ''); puts AllColourMethods.lightpink4(i); end
elightred(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 3355
def Colours.elightred(i = ''); puts AllColourMethods.lightred(i); end
elightsalmon(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 3746
def Colours.elightsalmon(i = ''); puts AllColourMethods.lightsalmon(i); end
elightsalmon1(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 3769
def Colours.elightsalmon1(i = ''); puts AllColourMethods.lightsalmon1(i); end
elightsalmon3(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 3792
def Colours.elightsalmon3(i = ''); puts AllColourMethods.lightsalmon3(i); end
elightseagreen(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 3815
def Colours.elightseagreen(i = ''); puts AllColourMethods.lightseagreen(i); end
elightskyblue(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 3838
def Colours.elightskyblue(i = ''); puts AllColourMethods.lightskyblue(i); end
elightskyblue1(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 3861
def Colours.elightskyblue1(i = ''); puts AllColourMethods.lightskyblue1(i); end
elightskyblue3(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 3884
def Colours.elightskyblue3(i = ''); puts AllColourMethods.lightskyblue3(i); end
elightslateblue(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 3907
def Colours.elightslateblue(i = ''); puts AllColourMethods.lightslateblue(i); end
elightslategray(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 3930
def Colours.elightslategray(i = ''); puts AllColourMethods.lightslategray(i); end
elightslategrey(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 3953
def Colours.elightslategrey(i = ''); puts AllColourMethods.lightslategrey(i); end
elightsteelblue(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 3976
def Colours.elightsteelblue(i = ''); puts AllColourMethods.lightsteelblue(i); end
elightsteelblue1(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 3999
def Colours.elightsteelblue1(i = ''); puts AllColourMethods.lightsteelblue1(i); end
elightsteelblue3(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 4022
def Colours.elightsteelblue3(i = ''); puts AllColourMethods.lightsteelblue3(i); end
elightyellow(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 4045
def Colours.elightyellow(i = ''); puts AllColourMethods.lightyellow(i); end
elightyellow3(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 4068
def Colours.elightyellow3(i = ''); puts AllColourMethods.lightyellow3(i); end
elime(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 4091
def Colours.elime(i = ''); puts AllColourMethods.lime(i); end
elimegreen(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 4114
def Colours.elimegreen(i = ''); puts AllColourMethods.limegreen(i); end
eliminate_html( i, use_this_colour_for_the_default_colour = :default, use_this_as_replacement_hash = :default_hash ) click to toggle source
#

Colours.eliminate_html

This method simply combines two other methods, without any further checks inside of this method. The method will thus remove entries such as <one> or <steelblue>.

#
# File lib/colours/toplevel_methods/methods_related_to_html_colours.rb, line 274
def self.eliminate_html(
    i,
    use_this_colour_for_the_default_colour = :default,
    use_this_as_replacement_hash           = :default_hash
  )
  i = i.dup
  i = Colours.replace_number_words_with_the_corresponding_html_colour(
    i,
    use_this_colour_for_the_default_colour,
    use_this_as_replacement_hash
  )
  i = i.dup
  i = Colours.replace_html_colours_in_this_string(
    i,
    use_this_colour_for_the_default_colour
  )
  return i.dup
end
elinen(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 4137
def Colours.elinen(i = ''); puts AllColourMethods.linen(i); end
emagenta(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 4160
def Colours.emagenta(i = ''); puts AllColourMethods.magenta(i); end
emagenta1(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 4183
def Colours.emagenta1(i = ''); puts AllColourMethods.magenta1(i); end
emagenta2(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 4206
def Colours.emagenta2(i = ''); puts AllColourMethods.magenta2(i); end
emagenta3(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 4229
def Colours.emagenta3(i = ''); puts AllColourMethods.magenta3(i); end
emaroon(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 4252
def Colours.emaroon(i = ''); puts AllColourMethods.maroon(i); end
emediumaquamarine(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 4275
def Colours.emediumaquamarine(i = ''); puts AllColourMethods.mediumaquamarine(i); end
emediumblue(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 4298
def Colours.emediumblue(i = ''); puts AllColourMethods.mediumblue(i); end
emediumorchid(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 4321
def Colours.emediumorchid(i = ''); puts AllColourMethods.mediumorchid(i); end
emediumorchid1(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 4344
def Colours.emediumorchid1(i = ''); puts AllColourMethods.mediumorchid1(i); end
emediumorchid3(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 4367
def Colours.emediumorchid3(i = ''); puts AllColourMethods.mediumorchid3(i); end
emediumpurple(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 4390
def Colours.emediumpurple(i = ''); puts AllColourMethods.mediumpurple(i); end
emediumpurple1(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 4413
def Colours.emediumpurple1(i = ''); puts AllColourMethods.mediumpurple1(i); end
emediumpurple2(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 4436
def Colours.emediumpurple2(i = ''); puts AllColourMethods.mediumpurple2(i); end
emediumpurple3(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 4459
def Colours.emediumpurple3(i = ''); puts AllColourMethods.mediumpurple3(i); end
emediumpurple4(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 4482
def Colours.emediumpurple4(i = ''); puts AllColourMethods.mediumpurple4(i); end
emediumseagreen(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 4505
def Colours.emediumseagreen(i = ''); puts AllColourMethods.mediumseagreen(i); end
emediumslateblue(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 4528
def Colours.emediumslateblue(i = ''); puts AllColourMethods.mediumslateblue(i); end
emediumspringgreen(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 4551
def Colours.emediumspringgreen(i = ''); puts AllColourMethods.mediumspringgreen(i); end
emediumturquoise(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 4574
def Colours.emediumturquoise(i = ''); puts AllColourMethods.mediumturquoise(i); end
emediumvioletred(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 4597
def Colours.emediumvioletred(i = ''); puts AllColourMethods.mediumvioletred(i); end
emidnightblue(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 4620
def Colours.emidnightblue(i = ''); puts AllColourMethods.midnightblue(i); end
emintcream(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 4643
def Colours.emintcream(i = ''); puts AllColourMethods.mintcream(i); end
emistyrose(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 4666
def Colours.emistyrose(i = ''); puts AllColourMethods.mistyrose(i); end
emistyrose1(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 4689
def Colours.emistyrose1(i = ''); puts AllColourMethods.mistyrose1(i); end
emistyrose3(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 4712
def Colours.emistyrose3(i = ''); puts AllColourMethods.mistyrose3(i); end
emoccasin(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 4735
def Colours.emoccasin(i = ''); puts AllColourMethods.moccasin(i); end
enable_colours( be_verbose = false ) click to toggle source
#

Colours.enable_colours

Use this method to enable colours for the whole Colours namespace.

#
# File lib/colours/toplevel_methods/use_colours.rb, line 86
def self.enable_colours(
    be_verbose = false
  )
  puts 'Enabling colours next.' if be_verbose
  @use_colours = true # Defined below.
end
enable_html_colours() click to toggle source
#

Colours.enable_html_colours

Use this method to specifically enable konsole-colours.

#
# File lib/colours/toplevel_methods/use_colours.rb, line 45
def self.enable_html_colours
  @use_html_colours = true
end
enavajowhite(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 4758
def Colours.enavajowhite(i = ''); puts AllColourMethods.navajowhite(i); end
enavajowhite1(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 4781
def Colours.enavajowhite1(i = ''); puts AllColourMethods.navajowhite1(i); end
enavajowhite3(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 4804
def Colours.enavajowhite3(i = ''); puts AllColourMethods.navajowhite3(i); end
enavy(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 4827
def Colours.enavy(i = ''); puts AllColourMethods.navy(i); end
enavyblue(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 4850
def Colours.enavyblue(i = ''); puts AllColourMethods.navyblue(i); end
eoldlace(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 4873
def Colours.eoldlace(i = ''); puts AllColourMethods.oldlace(i); end
eolive(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 4896
def Colours.eolive(i = ''); puts AllColourMethods.olive(i); end
eolivedrab(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 4919
def Colours.eolivedrab(i = ''); puts AllColourMethods.olivedrab(i); end
eorange(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 4942
def Colours.eorange(i = ''); puts AllColourMethods.orange(i); end
eorange1(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 4965
def Colours.eorange1(i = ''); puts AllColourMethods.orange1(i); end
eorange3(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 4988
def Colours.eorange3(i = ''); puts AllColourMethods.orange3(i); end
eorange4(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 5011
def Colours.eorange4(i = ''); puts AllColourMethods.orange4(i); end
eorangered(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 5034
def Colours.eorangered(i = ''); puts AllColourMethods.orangered(i); end
eorangered1(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 5057
def Colours.eorangered1(i = ''); puts AllColourMethods.orangered1(i); end
eorchid(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 5080
def Colours.eorchid(i = ''); puts AllColourMethods.orchid(i); end
eorchid1(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 5103
def Colours.eorchid1(i = ''); puts AllColourMethods.orchid1(i); end
eorchid2(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 5126
def Colours.eorchid2(i = ''); puts AllColourMethods.orchid2(i); end
epalegoldenrod(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 5149
def Colours.epalegoldenrod(i = ''); puts AllColourMethods.palegoldenrod(i); end
epalegreen(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 5172
def Colours.epalegreen(i = ''); puts AllColourMethods.palegreen(i); end
epalegreen1(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 5195
def Colours.epalegreen1(i = ''); puts AllColourMethods.palegreen1(i); end
epalegreen3(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 5218
def Colours.epalegreen3(i = ''); puts AllColourMethods.palegreen3(i); end
epaleturquoise(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 5241
def Colours.epaleturquoise(i = ''); puts AllColourMethods.paleturquoise(i); end
epaleturquoise1(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 5264
def Colours.epaleturquoise1(i = ''); puts AllColourMethods.paleturquoise1(i); end
epaleturquoise4(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 5287
def Colours.epaleturquoise4(i = ''); puts AllColourMethods.paleturquoise4(i); end
epalevioletred(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 5310
def Colours.epalevioletred(i = ''); puts AllColourMethods.palevioletred(i); end
epalevioletred1(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 5333
def Colours.epalevioletred1(i = ''); puts AllColourMethods.palevioletred1(i); end
epapayawhip(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 5356
def Colours.epapayawhip(i = ''); puts AllColourMethods.papayawhip(i); end
eparse(i = '') click to toggle source
#

Colours.eparse

This method primarily exists because we can easily split a string if it has a ‘#’ token. The part that comes after the ‘#’ token is assumed to be a comment or an explanation.

#
# File lib/colours/eparse/eparse.rb, line 93
def self.eparse(i = '')
  ::Colours.e(rparse(i)) # Defined in this file here.
end
epeachpuff(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 5379
def Colours.epeachpuff(i = ''); puts AllColourMethods.peachpuff(i); end
eperu(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 5402
def Colours.eperu(i = ''); puts AllColourMethods.peru(i); end
epink(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 5425
def Colours.epink(i = ''); puts AllColourMethods.pink(i); end
epink1(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 5448
def Colours.epink1(i = ''); puts AllColourMethods.pink1(i); end
epink3(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 5471
def Colours.epink3(i = ''); puts AllColourMethods.pink3(i); end
eplum(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 5494
def Colours.eplum(i = ''); puts AllColourMethods.plum(i); end
eplum1(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 5517
def Colours.eplum1(i = ''); puts AllColourMethods.plum1(i); end
eplum2(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 5540
def Colours.eplum2(i = ''); puts AllColourMethods.plum2(i); end
eplum3(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 5563
def Colours.eplum3(i = ''); puts AllColourMethods.plum3(i); end
eplum4(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 5586
def Colours.eplum4(i = ''); puts AllColourMethods.plum4(i); end
epowderblue(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 5609
def Colours.epowderblue(i = ''); puts AllColourMethods.powderblue(i); end
epurple(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 5632
def Colours.epurple(i = ''); puts AllColourMethods.purple(i); end
epurple3(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 5655
def Colours.epurple3(i = ''); puts AllColourMethods.purple3(i); end
epurple4(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 5678
def Colours.epurple4(i = ''); puts AllColourMethods.purple4(i); end
ered(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 5701
def Colours.ered(i = ''); puts AllColourMethods.red(i); end
ered1(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 5724
def Colours.ered1(i = ''); puts AllColourMethods.red1(i); end
ered3(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 5747
def Colours.ered3(i = ''); puts AllColourMethods.red3(i); end
erosybrown(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 5770
def Colours.erosybrown(i = ''); puts AllColourMethods.rosybrown(i); end
eroyalblue(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 5793
def Colours.eroyalblue(i = ''); puts AllColourMethods.royalblue(i); end
eroyalblue1(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 5816
def Colours.eroyalblue1(i = ''); puts AllColourMethods.royalblue1(i); end
esaddlebrown(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 5839
def Colours.esaddlebrown(i = ''); puts AllColourMethods.saddlebrown(i); end
esalmon(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 5862
def Colours.esalmon(i = ''); puts AllColourMethods.salmon(i); end
esalmon1(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 5885
def Colours.esalmon1(i = ''); puts AllColourMethods.salmon1(i); end
esandybrown(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 5908
def Colours.esandybrown(i = ''); puts AllColourMethods.sandybrown(i); end
eseagreen(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 5931
def Colours.eseagreen(i = ''); puts AllColourMethods.seagreen(i); end
eseagreen1(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 5954
def Colours.eseagreen1(i = ''); puts AllColourMethods.seagreen1(i); end
eseagreen2(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 5977
def Colours.eseagreen2(i = ''); puts AllColourMethods.seagreen2(i); end
eseagreen3(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 6000
def Colours.eseagreen3(i = ''); puts AllColourMethods.seagreen3(i); end
eseashell(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 6023
def Colours.eseashell(i = ''); puts AllColourMethods.seashell(i); end
esienna(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 6046
def Colours.esienna(i = ''); puts AllColourMethods.sienna(i); end
esilver(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 6069
def Colours.esilver(i = ''); puts AllColourMethods.silver(i); end
eskyblue(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 6092
def Colours.eskyblue(i = ''); puts AllColourMethods.skyblue(i); end
eskyblue1(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 6115
def Colours.eskyblue1(i = ''); puts AllColourMethods.skyblue1(i); end
eskyblue2(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 6138
def Colours.eskyblue2(i = ''); puts AllColourMethods.skyblue2(i); end
eskyblue3(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 6161
def Colours.eskyblue3(i = ''); puts AllColourMethods.skyblue3(i); end
eslateblue(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 6184
def Colours.eslateblue(i = ''); puts AllColourMethods.slateblue(i); end
eslateblue1(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 6207
def Colours.eslateblue1(i = ''); puts AllColourMethods.slateblue1(i); end
eslateblue3(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 6230
def Colours.eslateblue3(i = ''); puts AllColourMethods.slateblue3(i); end
eslategray(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 6253
def Colours.eslategray(i = ''); puts AllColourMethods.slategray(i); end
eslategrey(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 6276
def Colours.eslategrey(i = ''); puts AllColourMethods.slategrey(i); end
esnow(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 6299
def Colours.esnow(i = ''); puts AllColourMethods.snow(i); end
espringgreen(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 6322
def Colours.espringgreen(i = ''); puts AllColourMethods.springgreen(i); end
espringgreen1(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 6345
def Colours.espringgreen1(i = ''); puts AllColourMethods.springgreen1(i); end
espringgreen2(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 6368
def Colours.espringgreen2(i = ''); puts AllColourMethods.springgreen2(i); end
espringgreen3(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 6391
def Colours.espringgreen3(i = ''); puts AllColourMethods.springgreen3(i); end
espringgreen4(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 6414
def Colours.espringgreen4(i = ''); puts AllColourMethods.springgreen4(i); end
esteelblue(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 6437
def Colours.esteelblue(i = ''); puts AllColourMethods.steelblue(i); end
esteelblue1(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 6460
def Colours.esteelblue1(i = ''); puts AllColourMethods.steelblue1(i); end
esteelblue3(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 6483
def Colours.esteelblue3(i = ''); puts AllColourMethods.steelblue3(i); end
esystem(i) click to toggle source
#

esystem

#
# File lib/colours/toplevel_methods/esystem.rb, line 14
def self.esystem(i)
  e i
  system i
end
etan(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 6506
def Colours.etan(i = ''); puts AllColourMethods.tan(i); end
eteal(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 6529
def Colours.eteal(i = ''); puts AllColourMethods.teal(i); end
ethistle(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 6552
def Colours.ethistle(i = ''); puts AllColourMethods.thistle(i); end
ethistle1(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 6575
def Colours.ethistle1(i = ''); puts AllColourMethods.thistle1(i); end
ethistle3(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 6598
def Colours.ethistle3(i = ''); puts AllColourMethods.thistle3(i); end
etomato(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 6621
def Colours.etomato(i = ''); puts AllColourMethods.tomato(i); end
eturquoise(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 6644
def Colours.eturquoise(i = ''); puts AllColourMethods.turquoise(i); end
eturquoise2(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 6667
def Colours.eturquoise2(i = ''); puts AllColourMethods.turquoise2(i); end
eturquoise4(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 6690
def Colours.eturquoise4(i = ''); puts AllColourMethods.turquoise4(i); end
eviolet(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 6713
def Colours.eviolet(i = ''); puts AllColourMethods.violet(i); end
ewarn( i = '', make_newline = false ) click to toggle source
#

Colours.ewarn

#
# File lib/colours/colour_methods/colour_methods.rb, line 419
def self.ewarn(
    i            = '',
    make_newline = false
  )
  e swarn(i, make_newline)
end
ewheat(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 6736
def Colours.ewheat(i = ''); puts AllColourMethods.wheat(i); end
ewheat1(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 6759
def Colours.ewheat1(i = ''); puts AllColourMethods.wheat1(i); end
ewheat4(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 6782
def Colours.ewheat4(i = ''); puts AllColourMethods.wheat4(i); end
ewhite(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 6805
def Colours.ewhite(i = ''); puts AllColourMethods.white(i); end
ewhitesmoke(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 6828
def Colours.ewhitesmoke(i = ''); puts AllColourMethods.whitesmoke(i); end
eyellow(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 6851
def Colours.eyellow(i = ''); puts AllColourMethods.yellow(i); end
eyellow1(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 6874
def Colours.eyellow1(i = ''); puts AllColourMethods.yellow1(i); end
eyellow2(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 6897
def Colours.eyellow2(i = ''); puts AllColourMethods.yellow2(i); end
eyellow3(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 6920
def Colours.eyellow3(i = ''); puts AllColourMethods.yellow3(i); end
eyellow4(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 6943
def Colours.eyellow4(i = ''); puts AllColourMethods.yellow4(i); end
eyellowgreen(i = '') click to toggle source
# File lib/colours/autogenerated/toplevel_basic_colour_methods.rb, line 6966
def Colours.eyellowgreen(i = ''); puts AllColourMethods.yellowgreen(i); end
fancy_parse( i = '', use_this_colour = :default_colour ) click to toggle source
#

Colours.fancy_parse

This method can be used to parse a line containing special tags, such as <i> or <teal>, and replace them with the corresponding ASCII code for the commandline. The second example, e. g. <teal>, is known as a HTML colour tag (htmlcolour).

The idea for this method is to simply use it to quickly colourize some arbitrary text.

The method will only return the resulting, sanitizing String; if you wish to display this on the terminal/commandline then you will have to use puts or print on your own.

Usage examples:

alias e puts
e Colours.fancy_parse '<i><red>E. coli</red></i>'
e Colours.fancy_parse '<i><lightgreen>E. coli</lightgreen></i>'
e Colours.fancy_parse "<lightgreen><i>hey</i></lightgreen> <teal>there</teal>"
e Colours.fancy_parse "<tomato>hey</tomato> <teal>there</teal>"
e Colours.fancy_parse "<tomato><i>hey</i></tomato> <teal>there</teal>"
e Colours.fancy_parse "<tomato><b>Hello world.</b></tomato>"
e Colours.fancy_parse "<tomato>Hello world.</tomato>"
e Colours.fancy_parse '<i>hey</i> <teal>there</teal>'
e Colours.fancy_parse '<i>hey</i> <teal>there</teal> ok'
e Colours.fancy_parse "<lightgreen><i>hey</i></lightgreen> <teal>there</teal>"
e Colours.fancy_parse "<tomato>hey</tomato> <teal>there</teal>"
e Colours.fancy_parse "<tomato><i>hey</i></tomato> <teal>there</teal>"
e Colours.fancy_parse "<tomato><b><i>hey</i></b></tomato> <teal>there</teal>"
e Colours.fancy_parse "<tomato><b><i>hey</i></b></tomato> <teal>there</teal> <b>how do you do</b>"
e Colours.fancy_parse "<tomato><b>Hello world.</b></tomato>"
#
# File lib/colours/class/colours.rb, line 403
def self.fancy_parse(
    i               = '',
    use_this_colour = :default_colour
  )
  if i.is_a? Array
    i = i.join # We do not want an Array past this point.
  end
  # ========================================================================= #
  # === Handle italic tags, aka <i>
  #
  # The old code was:
  #
  #  i.gsub!(use_this_regex, return_italic('\1'))
  #
  # Up until November 2022, then it was changed.
  # ========================================================================= #
  if i.include?('<i>') and i.include?('</i>')
    # ======================================================================= #
    # The following regex is defined at:
    #
    #   https://rubular.com/r/k5tE9xBzky8muR
    #
    # ======================================================================= #
    use_this_regex = /<i>([<>\/\.A-Za-zöäüÖÄÜ\s-]*?)<\/i>/
    i = i.dup if i.frozen?
    i.gsub!(
      use_this_regex,
      ::Colours::Colours.new('\1').italic.to_s+ # or return_italic('\1')
      ::Colours.rev
    )
  end
  # ========================================================================= #
  # === Handle bold tags, aka <b>
  # ========================================================================= #
  if i.include?('<b>') and i.include?('</b>')
    use_this_regex = /<b>(.+)<\/b>/
    i.gsub!(
      use_this_regex,
      ::Colours::Colours.new('\1').bold.to_s # or return_bold('\1')
    )
  end
  # ========================================================================= #
  # Finally, handle all HTML colours in the given line.
  # ========================================================================= #
  i = replace_all_html_colours_in_this_line(i, use_this_colour)
  return i
end
file_html_colours_to_rgb?() click to toggle source
#

Colours.file_html_colours_to_rgb?

Easier toplevel-getter method to determine where the file for the html-colours-to-rgb conversion resides.

#
# File lib/colours/constants/file_constants.rb, line 54
def self.file_html_colours_to_rgb?
  "#{PROJECT_BASE_DIRECTORY}yaml/html_colours.yml"
end
generate_shell_file_containing_the_html_colours( generate_the_shell_file_into_this_directory = Dir.pwd ) click to toggle source
#

Colours.generate_shell_file_containing_the_html_colours

This method will generate a shell file into the current directory by default.

The code in that file will generate a shell script that holds all the HTML-colours, via UPCASED names.

These entries will then look like this:

SADDLEBROWN:  "\e[38;2;139;69;19m"
PERU:         "\e[38;2;205;133;63m"
CHOCOLATE:    "\e[38;2;210;105;30m"
#
# File lib/colours/toplevel_methods/autogenerate.rb, line 243
def self.generate_shell_file_containing_the_html_colours(
    generate_the_shell_file_into_this_directory = Dir.pwd
  )
  require 'save_file/module'
  unless generate_the_shell_file_into_this_directory.end_with? '/'
    if generate_the_shell_file_into_this_directory.frozen?
      generate_the_shell_file_into_this_directory = generate_the_shell_file_into_this_directory.dup
    end
    generate_the_shell_file_into_this_directory << '/'
  end
  result = ''.dup
  result << "# This is a shell file that contains the HTML colours\n"
  available_html_colours?.each {|this_colour|
    colour_code_to_use = ::Colours.html_colourize(this_colour.to_sym,'',false).inspect
    result << "export #{this_colour.upcase}=#{colour_code_to_use}\n"
  }
  generate_the_shell_file_into_this_directory << 'shell_file_containing_the_html_colours.sh'
  into = generate_the_shell_file_into_this_directory
  e "Now creating a shell file at `#{into}`."
  SaveFile.write_what_into(result, into)
  # ======================================================================= #
  # Generate files on my home system as well:
  # ======================================================================= #
  if is_on_roebe?
    into = '/home/x/programming/ruby/src/'\
           'roebe/lib/roebe/shell_scripts/'+
           File.basename(generate_the_shell_file_into_this_directory)
    puts "And also saving into `#{into}`."
    SaveFile.write_what_into(result, into)
  end
end
hash_html_colours?() click to toggle source
#

Colours.hash_html_colours?

#
# File lib/colours/html_colours/html_colours.rb, line 313
def self.hash_html_colours?
  ::Colours::HtmlColours.hash_html_colours?
end
html_colour_to_hex_value( this_html_colour, return_with_hash_key = true ) click to toggle source
#

Colours.html_colour_to_hex_value

#
# File lib/colours/toplevel_methods/html_colour_to_hex_value.rb, line 15
def self.html_colour_to_hex_value(
    this_html_colour,
    return_with_hash_key = true
  )
  if this_html_colour.is_a? Array
    this_html_colour = this_html_colour.first
  end
  _ = file_html_colours_to_rgb?
  if File.exist? _
    # ===================================================================== #
    # Load the yaml-file next:
    # ===================================================================== #
    dataset = YAML.load_file(_)
    if dataset.has_key? this_html_colour
      _ = dataset[this_html_colour].last
      if return_with_hash_key
        _ = _.dup if _.frozen?
        _ = _.to_s unless _.is_a? String
        _[0,0] = '#' if _.respond_to? :[]=
      end
      return _
    end
  end
  return this_html_colour
end
html_colour_to_rgb_value( this_html_colour = 'slateblue' ) click to toggle source
#

Colours.html_colour_to_rgb_value

This method will return a String, representing the RGB values.

It will, other than that, not make any other modifications; in particular it will NOT append a trailing “m” token.

By default the R, G, B values will be separated via a ‘;’ token. If you don’t want this then modify it e. g. via: .tr(‘;’,‘,’).

Usage examples:

Colours.html_colour_to_rgb_value('slateblue') # => "106;90;205"
Colours.html_colour_to_rgb_value('crimson')   # => "220;20;60"
Colours.html_colour_to_rgb(:steelblue)        # => "70;130;180"
#
# File lib/colours/rgb/rgb.rb, line 466
def self.html_colour_to_rgb_value(
    this_html_colour = 'slateblue'
  )
  _ = ::Colours.convert_this_html_colour_into_an_array_of_rgb_values(this_html_colour.to_sym)
  return "#{_[0]};#{_[1]};#{_[2]}"
end
html_colourize( colour_to_use = return_random_html_colour, this_text = nil, append_revert = true ) { || ... } click to toggle source
#

Colours.html_colourize

This method will simply return the colour-code + text.

The third argument, called ‘append_revert`, can be used to determine whether we will append the revert code to the generated output String or whether we will not. By default we will, but there are examples where we may wish to assemble our own colour string, and in these cases we do not yet know which text is to be shown - hence, this must become an optional argument.

A block can be passed to this method. If the block has, as content, the Symbol :omit_end then the end-part of the ANSI code will not be used.

Usage examples:

x = Colours.colourize('slateblue', 'Hello world!'); pp x
y = Colours.colourize('slateblue', 'Hello world!') { :omit_end }; pp y
#
# File lib/colours/toplevel_methods/html_colourize.rb, line 33
def self.html_colourize(
    colour_to_use = return_random_html_colour,
    this_text     = nil,
    append_revert = true,
    &block
  )
  require 'colours/html_colours/html_colours.rb'
  require 'colours/rgb/rgb.rb'
  if block_given?
    yielded = yield
    case yielded
    # ===================================================================== #
    # === :omit_end
    # ===================================================================== #
    when :omit_end
      append_revert = false
    end
  end
  if this_text.nil?
    this_text = colour_to_use.to_s.dup
  end
  if append_revert
    "#{rgb_value_as_escape_code_string(colour_to_use)}#{this_text}#{revert}"
  else
    "#{rgb_value_as_escape_code_string(colour_to_use)}#{this_text}"
  end
end
is_a_valid_colour?(i) click to toggle source
#

Colours.is_a_valid_colour?

This method allows you to check if a given input-string is a valid colour.

A “valid” colour is one that the colours project supports.

For example, the string “lightblue” is a valid colour.

Usage example:

Colours.is_a_valid_colour? 'lightblue'
#
# File lib/colours/constants/hash_simple_colours.rb, line 144
def self.is_a_valid_colour?(i)
  ALL_COLOURS.include? i.to_sym
end
is_on_roebe?() click to toggle source
#

Colours.is_on_roebe?

#
# File lib/colours/toplevel_methods/is_on_roebe.rb, line 12
def self.is_on_roebe?
  ENV['IS_ROEBE'].to_s == '1'
end
is_this_a_256_colour?(i) click to toggle source
#

Colours.is_this_a_256_colour?

Invocation example:

Colours.is_this_a_256_colour? 'LightSteelBlue3'
#
# File lib/colours/256_colours/support_for_256_colours.rb, line 171
def self.is_this_a_256_colour?(i)
  if @dataset_for_the_256_colours
    @dataset_for_the_256_colours.keys.map(&:downcase).include?(i.to_s.downcase)
  else
    false
  end
end
italic( i = '', make_newline = false, &block ) click to toggle source
#

Colours.italic

This method will “puts” the result of applying italic to a string, on the console/terminal. If you wish to do the output on your own then you have to use the method Colours.return_italic or its alias called Colours.string_italic.

To test this, try:

Colours.italic('Hello world!')
#
# File lib/colours/toplevel_methods/italic.rb, line 66
def self.italic(
    i            = '', 
    make_newline = false,
    &block
  )
  e return_italic(i, make_newline, &block)
end
left?() click to toggle source
#

Colours.left?

#
# File lib/colours/constants/misc.rb, line 121
def self.left?
  LEFT
end
make_colour( what_colour_to_use ) click to toggle source
#

Colours.make_colour

This is used primarily for testing.

#
# File lib/colours/toplevel_methods/make_colour.rb, line 17
def self.make_colour(
    what_colour_to_use
  )
  i = what_colour_to_use # Copy.
  constant = i.to_s.upcase
  name_of_colour = const_get(constant)
  string = '%-34s' % ("#{name_of_colour} Test with #{constant}.")
  string << IS_A_TEST+'('+name_of_colour.inspect.delete('"')+')'
  e(string)
end
map_symbol_to_corresponding_colour(i) click to toggle source
#

Colours.map_symbol_to_corresponding_colour (menu tag)

This method will accept a symbol as input, such as :bold_blue, and return the corresponding CONSTANT (or rather, the value this constant refers to). This allows us to “map” the respective symbol to the corresponding constant.

For example, the Symbol :bold_blue will correspond to the BOLD_BLUE constant. The Symbol :bold_green will correspond to the BOLD_GREEN constant (or COLOUR_BOLD_GREEN; there are some “aliases” on the constant-level as well). This constant thus represents the symbol at hand.

Take note that this method here has several aliases:

Colours.translate()
Colours.beautify()
Colours.convert()
Colours.parse()
Colours.map_colour_to_constant()

This is partially due to historic reasons; and partially simply

because some of them are shorter and hence easier to type.

Usage example for this method:

Colours.beautiful(:bold_blue)
#
# File lib/colours/map_symbol_to_corresponding_colour/map_symbol_to_corresponding_colour.rb, line 42
def self.map_symbol_to_corresponding_colour(i)
  if i.is_a? String # Handle Strings as well.
    # ===================================================================== #
    # === random
    # ===================================================================== #
    if i == 'random' # Fetch a random entry in this case.
      i = MAIN_COLOURS.sample
    end
    i = i.tr(' ','_').to_sym
  end
  case i # case tag
  # ======================================================================= #
  # === :default
  # ======================================================================= #
  when :default,
       :si,
       :default_colour,
       :defaultcolour,
       :normal,
       nil
    return DEFAULT_COLOUR
  # ======================================================================= #
  # === :light_grey
  # ======================================================================= #
  when :light_grey,
       :grey
    return COLOUR_LIGHT_GREY
  # ======================================================================= #
  # === :bold_green
  # ======================================================================= #
  when :bold_green,
       :boldgreen,
       :bright_green,
       :greenb,
       :lightgreen
    return BOLD_GREEN # => "\e[1;32m"
  # ======================================================================= #
  # === :bold_brown
  # ======================================================================= #
  when :bold_brown,
       :bbrown,
       :gold,
       :saddlebrown
    return BOLD_BROWN
  # ======================================================================= #
  # === :white
  # ======================================================================= #
  when :white,
       :whitebonblack
    return WHITE
  # ======================================================================= #
  # === :red
  # ======================================================================= #
  when :red
    return RED
  # ======================================================================= #
  # === :pink
  # ======================================================================= #
  when :pink,
       :bright_magenta
    return BRIGHT_MAGENTA
  # ======================================================================= #
  # === :bright_cyan
  # ======================================================================= #
  when :bright_cyan,
       :cyanb,
       :cyan
    return BOLD_CYAN
  # ======================================================================= #
  # === :brown
  # ======================================================================= #
  when :brown
    return BROWN
  # ======================================================================= #
  # === :yellow
  # ======================================================================= #
  when :yellow,
       :yel
    return YELLOW
  # ======================================================================= #
  # === :green
  # ======================================================================= #
  when :green,
       :greengreen
    return GREEN
  # ======================================================================= #
  # === :blue
  # ======================================================================= #
  when :blue
    return BLUE
  # ======================================================================= #
  # === :magenta
  # ======================================================================= #
  when :magenta
    return MAGENTA
  # ======================================================================= #
  # === :teal
  # ======================================================================= #
  when :teal
    return TEAL
  # ======================================================================= #
  # === :revert
  # ======================================================================= #
  when :revert,
       :reset,
       :clear
    return REVERT
  # ======================================================================= #
  # === :bold_red
  # ======================================================================= #
  when :bold_red,
       :boldred,
       :bright_red,
       :lightred,
       :redb
    return BOLD_RED
  # ======================================================================= #
  # === :lightblue
  # ======================================================================= #
  when :lightblue
    return LIGHTBLUE
  # ======================================================================= #
  # === :bold_yellow
  # ======================================================================= #
  when :bold_yellow,
       :boldyellow,
       :yelb,
       :bright_yellow,
       :byellow
    return BOLD_YELLOW
  # ======================================================================= #
  # === :bold_blue
  # ======================================================================= #
  when :bold_blue,
       :boldblue,
       :bright_blue,
       :blueb
    return BOLD_BLUE
  # ======================================================================= #
  # === :bold_white
  # ======================================================================= #
  when :bold_white,
       :boldwhite,
       :bright_white
    return BOLD_WHITE
  # ======================================================================= #
  # === :black
  # ======================================================================= #
  when :black,
       :bold_black,
       :boldblack,
       :bright_black
    return COLOUR_BLACK
  else
    puts "Unknown symbol given as input: #{i}"
    pp i
  end
  i # else return the input-argument again.
end
map_this_symbol_to_that_256_colour(i) click to toggle source
#

Colours.map_this_symbol_to_that_256_colour

This method will take input such as :bold_green and associate it with a corresponding 256-colour. Thus, the resulting Symbol that is found here should correspond to a method on module SupportFor256Colours.

#
# File lib/colours/colour_table/colour_table.rb, line 113
def self.map_this_symbol_to_that_256_colour(i)
  case i
  when :boldgreen,
       :bold_green
    :chartreuse2
  when :teal
    :teal
  when :bold_yellow
    :yellow2
  when :gold
    :gold3
  when :bold_blue
    :lightslateblue
  when :bold_brown
    :darkred
  when :brown
    :maroon
  when :pink
    :hotpink3
  when :lightgrey,
       :light_grey
    :grey66
  when :bold_red
    :red1
  when :lightblue,
       :light_blue
    :deepskyblue3
  when :grey
    :grey53
  when :green
    :chartreuse4
  else
    puts "Not known input to method #{__method__.to_s}: #{i}"
  end
end
map_this_symbol_to_that_html_colour(i) click to toggle source
#

Colours.map_this_symbol_to_that_html_colour

The job of this method is to map entries such as :bold_green to a corresponding HTML colour.

#
# File lib/colours/colour_table/colour_table.rb, line 80
def self.map_this_symbol_to_that_html_colour(i)
  if is_a_html_colour? i
    i
  else
    case i
    # === :cyanb
    when :cyanb
      :lightseagreen
    # === :light_grey
    when :light_grey
      :lightgray
    # === :bold_blue
    when :bold_blue
      :slateblue
    when :bold_red, :redb
      :crimson
    when :bold_yellow
      :goldenrod
    when :bold_green
      :seagreen
    else
      puts 'Unregistered input into the method '+__method__.to_s+': '+i.to_s
    end
  end
end
menu( i = ::Colours.commandline? ) click to toggle source
#

Colours.menu (menu tag)

To invoke this method, try:

colours --show_html_colours
colours file?
#
new(i = ARGV) click to toggle source
#

Colours.new

#
# File lib/colours/class/colours.rb, line 454
def self.new(i = ARGV)
  ::Colours::Colours.new(i)
end
prefer_which_colour_schemata?() click to toggle source
#

Colours.prefer_which_colour_schemata?

#
# File lib/colours/toplevel_methods/prefer_this_colour_schemata.rb, line 77
def self.prefer_which_colour_schemata?
  @prefer_this_colour_schemata[1].to_sym if @prefer_this_colour_schemata
end
project_base_dir?() click to toggle source
#

Colours.project_base_dir?

#
# File lib/colours/project/project.rb, line 18
def self.project_base_dir?
  PROJECT_BASE_DIRECTORY
end
random_colour?() click to toggle source
#

Colours.random_colour?

Obtain a random sample, aka a random colour, from all the registered html colours.

#
# File lib/colours/html_colours/html_colours.rb, line 281
def self.random_colour?
  ::Colours::HtmlColours.random_colour?
end
random_html_colour() click to toggle source
#

Colours.random_html_colour

This method will simply return a (one) random HTML colour, in long format, e. g. “teal” or “slateblue”.

If you wish to have it colourized properly, you need to use another method.

Usage examples:

Colours.random_colour? # => "teal"
Colours.random_colour? # => "blueviolet"
#
# File lib/colours/html_colours/html_colours.rb, line 369
def self.random_html_colour
  ::Colours::HtmlColours.random_colour?
end
random_html_colour_with_this_text( use_this_text = '' ) click to toggle source
#

Colours.random_html_colour_with_this_text

The first argument is the text that we wish to display.

Usage example:

puts Colours.random_html_colour_with_this_text 'foo bar'
#
# File lib/colours/rgb/rgb.rb, line 333
def self.random_html_colour_with_this_text(
      use_this_text = ''
    )
  "#{rgb_value_as_escape_code_string}#{use_this_text}#{restore?}"
end
random_value?() click to toggle source
#

Colours.random_value?

We will obtain a random value between 0 and 255, hence why we will use rand(256).

#
# File lib/colours/toplevel_methods/random_value.rb, line 15
def self.random_value?
  rand(256)
end
read_and_display_this_file( i = TEST_FILE ) click to toggle source
#

Colours.read_and_display_this_file

This method accepts a file path - in other words, the input should be the location of a specific file on your filesystem - and then simply reads in the content of said file via File.readlines().

Content such as <slateblue> found in this file will be replaced with the respective R,G,B substring value.

In the test/ subdirectory there is an example file for this - have a look there for more information.

#
# File lib/colours/toplevel_methods/misc.rb, line 90
def self.read_and_display_this_file(
    i = TEST_FILE
  )
  i = i.to_s
  if File.exist? i
    new_array = []
    data = File.readlines(i)
    data.each {|entry|
      # ======================================================================= #
      # Check whether the entry has a <> tag:
      # ======================================================================= #
      if entry.include?('<') and entry.include?('>') and 
         entry.include?('</>')
        # ================================================================= #
        # Ok, we may assume that something like <slateblue> is there.
        # ================================================================= #
        entry = sanitize_line(entry)
      end
      new_array << entry
    }
    e new_array # For now we will simply output that modified Array.
  else
    e "Notice: The file at `#{sfile(i)}` does not exist."
  end
end
really_all_colours() click to toggle source
#

Colours.really_all_colours

This method will return an Array that may look like this:

[:black, :red, :green, :yellow, :blue, :magenta, :teal,
 :white, :bright_black, :bright_red, :bright_green,
 :bright_yellow, :bright_blue, :bright_magenta,
 :bright_cyan, :bright_white]
#
# File lib/colours/constants/hash_simple_colours.rb, line 125
def self.really_all_colours
  ALL_COLOURS # This is the conjoint Array.
end
remove_escape_sequence(i = ARGV) click to toggle source
#

Colours.remove_escape_sequence

The method Colours.remove_escape_sequence() will remove all Ansi Escape sequences from a given string.

#
# File lib/colours/toplevel_methods/remove_escape_sequence.rb, line 18
def self.remove_escape_sequence(i = ARGV)
  if i.is_a? Array
    i = i.join("\n")
  end
  i = i.to_s.dup
  # ======================================================================= #
  # Iterate over the registered ansi-colours next.
  # ======================================================================= #
  ARRAY_REGISTERED_ANSI_COLOURS.each {|entry|
    if i.include? entry
      entry = Regexp.quote(entry)
      i.sub!(/#{entry}/, '')
    end
    # ===================================================================== #
    # Next, check for KDE konsole colours. We must use "" there, not ''.
    # ===================================================================== #
    if i.include?("\e[") and i =~ /\d+m/ # Such as: "\e[38;2;220;20;60m|"
      # =================================================================== #
      # The next regex will (hopefully) remove all escape-characters
      # from the given String.
      # =================================================================== #
      regex_for_html_colours = # Detect entries such as: \e[38;2;106;90;205m
        /(\e\[\d{2};\d{1};\d{3};\d{1,2};\d{3}m)/ # See: https://rubular.com/r/tG3XeOK5NPsfmI
      i.gsub!(regex_for_html_colours, '')
      # =================================================================== #
      # See: https://rubular.com/r/SdS28fAGSxIELn
      # =================================================================== #
      # /(\\e\[\d{1,2};?\d{1,2};?\d{0,3};?\d{0,3};?\d{1,2}m|\\e\[\d{0,2}m|\\e\[K|\\e\[\d{0,2};\d{0,2}m|(\\e\[.+\dm)|\\e\[0;37m)/
      [
        /\e\[\d{1,2};?\d{1,2};?\d{0,3};?\d{0,3};?\d{1,2}m/,
        /\\e\[\d{0,2}m|\\e\[K|\\e\[\d{0,2};\d{0,2}m/,
        /\\e\[.+\dm/,
        /\\e\[0;37m/
      ].each {|regex_to_use|
        i.gsub!(regex_to_use, '')
      }
    end
  }
  return i
end
remove_trailing_end_from( i, remove_this_escape_sequence = revert? ) click to toggle source
#

Colours.remove_trailing_end_from

The second argument to this method can be the escape sequence that you wish to remove.

Invocation example:

x = Colours.remove_trailing_end_from("\e[38;2;70;130;180m\e[0;37m") # => "\e[38;2;70;130;180m"
#
# File lib/colours/toplevel_methods/remove_escape_sequence.rb, line 73
def self.remove_trailing_end_from(
    i,
    remove_this_escape_sequence = revert?
  )
  quoted = Regexp.quote(remove_this_escape_sequence)
  # ======================================================================= #
  # Anchor it at the end via $.
  # ======================================================================= #
  return i.sub(
    /#{quoted}$/, ''
  )
end
replace_html_colours_in_this_string( i, use_this_colour_for_the_default_colour = :default, shall_we_revert_at_the_end_of_the_line = true ) click to toggle source
#

Colours.replace_html_colours_in_this_string

This method will replace all HTML colours in a given string, such as “<slateblue>test</slateblue>”, with the corresponding RGB colour variant for the commandline.

Typically this refers to a terminal such as the KDE Konsole, and a shell such as bash (although other shells are fine too, and many other terminals, such as the gnome-terminal, most likely will work fine as well - but it is optimized for the KDE Konsole).

This method should only be called after a prior check was done, to determine whether the given input String at hand does indeed include a valid HTML colour; otherwise it would be fairly pointless to invoke this method, if it is already known that the String at hand does not contain any HTML colour at all. In order to determine whether a String may include a valid HTML colour, the method called line_contains_a_valid_html_colour?() can be used.

Usage example:

Colours.replace_html_colours_in_this_string
Colours.replace_html_colours_in_this_string('- The <one>UID</one> of <royalblue>the</royalblue> user called <two>root</two> is ... ? <one>0</one>.', :lightgreen)
#
# File lib/colours/toplevel_methods/methods_related_to_html_colours.rb, line 186
def self.replace_html_colours_in_this_string(
    i,
    use_this_colour_for_the_default_colour = :default, # ← This specifies the default colour.
    shall_we_revert_at_the_end_of_the_line = true
  )
  i = i.dup # We want to work on a copy.
  result = ''.dup # Our result-string.
  case use_this_colour_for_the_default_colour
  # ======================================================================= #
  # === :default
  # ======================================================================= #
  when :default,
       :default_colour
    use_this_colour_for_the_default_colour = USE_THIS_COLOUR_FOR_THE_DEFAULT_COLOUR
  end
  case shall_we_revert_at_the_end_of_the_line
  # ======================================================================= #
  # === :revert
  # ======================================================================= #
  when :revert
    shall_we_revert_at_the_end_of_the_line = true
  end
  result << ::Colours::AllColourMethods.send(use_this_colour_for_the_default_colour) { :omit_end }
  # result = result.dup
  # ======================================================================= #
  # This method will make use of two different regexes.
  # ======================================================================= #
  scanned_results = i.scan(
    REGEX_FOR_HTML_COLOURS
  ).flatten.uniq
  add_on_string = i.dup
  # ======================================================================= #
  # scanned_results may be an Array such as ['steelblue', 'tomato']
  # ======================================================================= #
  scanned_results.each {|this_colour|
    if is_this_a_valid_html_colour?(this_colour)
      # =================================================================== #
      # We must use .gsub!() because the colour-string may occur more
      # than once. Unfortunately for longer Strings this becomes a bit
      # fragile.
      # =================================================================== #
      part1 = ::Colours::AllColourMethods.send(this_colour.to_sym, "\\1") { :omit_end }
      part2 = ::Colours::AllColourMethods.send(use_this_colour_for_the_default_colour) { :omit_end }
      add_on_string.gsub!(
        Colours.return_main_regex_to_use_for_obtaining_the_full_content(this_colour),
        part1+part2
      ).dup
    end
  }
  result << add_on_string
  if shall_we_revert_at_the_end_of_the_line
    result << ::Colours.revert
  end
  return result
end
replace_number_words_with_the_corresponding_html_colour( i, use_this_as_replacement_hash = :default ) click to toggle source
#

Colours.replace_number_words_with_the_corresponding_html_colour

The input to this method should be the String that contains HTML numbers such as <one> or <two>.

This method can be customized a bit. One way to customize it is to pass the default colour to this method, as second argument. The default colour is (currently, in Oct 2020) grey.

The third argument is a Hash. This Hash can be used to denote the default colours for <one>, <two> and so forth. So if you want to change the colours, pass in your own Hash into this method.

Usage examples:

x = Colours.replace_number_words_with_the_corresponding_html_colour("- <teal>Asbestbedingte Erkrankungen</teal> haben eine <two>Latenzzeit</two> von etwa n Jahren? Etwa <steelblue>30 Jahren</steelblue>.")
x = "<one>Methämoglobin</one> ist <two>ungeeignet</two> für <three>den</three> Sauerstofftransport; die <two>roten Blutkörperchen</two>. Welches Enzymsystem ist dies?"
y = Colours.replace_number_words_with_the_corresponding_html_colour(x)

See also:

https://rubular.com/r/XUPQJFKlDs2OYP
#
# File lib/colours/toplevel_methods/methods_related_to_html_colours.rb, line 86
def self.replace_number_words_with_the_corresponding_html_colour(
    i,
    use_this_as_replacement_hash = :default
  )
  # ======================================================================= #
  # Specify our "replacement-hash", that is colours used for e. g.
  # <one>, <two> or <three>.
  # ======================================================================= #
  case use_this_as_replacement_hash
  # ======================================================================= #
  # === :default
  # ======================================================================= #
  when :default,
       :default_hash
    # ===================================================================== #
    # The following hash can be used as a default "replacement" Hash.
    # ===================================================================== #
    use_this_as_replacement_hash = {
      one:            :teal,
      two:            :lightseagreen,
      three:          :mediumseagreen, # ← Used to be 'peru' up until 23.11.2019.
      four:           :mediumorchid,   # ← Used to be 'olivedrab' up until 06.12.2022.
      five:           :lightgreen,
      default_colour: USE_THIS_COLOUR_FOR_THE_DEFAULT_COLOUR # Defined on top.
    }
  end
  # ======================================================================= #
  # === :default_colour
  # ======================================================================= #
  if use_this_as_replacement_hash.has_key? :default_colour
    use_this_colour_for_the_default_colour = use_this_as_replacement_hash[:default_colour]
  end
  # ======================================================================= #
  # === Enable support for <one>, <two>, <three>, <four> and <five> next.
  # ======================================================================= #
  if i.include?('<one>')   or
     i.include?('<two>')   or
     i.include?('<three>') or
     i.include?('<four>')  or
     i.include?('<five>')
    scanned_results = i.scan(
      REGEX_FOR_HTML_COLOURS
    ).flatten.uniq
    scanned_results.each {|this_numbered_word|
      # =================================================================== #
      # Since as of December 2021 we only accept Symbols here.
      # =================================================================== #
      this_numbered_word = this_numbered_word.to_sym
      if use_this_as_replacement_hash.has_key? this_numbered_word
        i = i.dup if i.frozen?
        replacement_colour = use_this_as_replacement_hash[this_numbered_word]
        use_this_regex =
          # =============================================================== #
          # We will simply re-use the regex-generator near the top of this
          # file here.
          # =============================================================== #
          ::Colours.return_main_regex_to_use_for_obtaining_the_full_content(this_numbered_word)
        # ================================================================= #
        # We must use .gsub!() because the colour-string may occur more
        # than once.
        # ================================================================= #
        i.gsub!(
          use_this_regex,
          ::Colours::AllColourMethods.send(replacement_colour.to_sym, "\\1")       { :omit_end }+
          ::Colours::AllColourMethods.send(use_this_colour_for_the_default_colour) { :omit_end }
        )
        # i << ::Colours.revert
      end
    }
  end
  return i
end
report_whether_colours_will_be_used() click to toggle source
#

Colours.report_whether_colours_will_be_used

#
# File lib/colours/toplevel_methods/use_colours.rb, line 121
def self.report_whether_colours_will_be_used
  if @use_colours
    puts 'Yes, colours will be used.'
  else
    puts 'Colours are currently disabled.'
  end
end
require_the_colour_methods() click to toggle source
#

Colours.require_the_colour_methods

This method will batch-require the .rb files that are found in the colour_methods/ subdirectory of the colours gem.

#
# File lib/colours/requires/require_the_colour_methods.rb, line 23
def self.require_the_colour_methods
  target = "#{::Colours::PROJECT_BASE_DIRECTORY}colour_methods/"

  Dir["#{target}*.rb"].each {|this_file|
    require target+File.basename(this_file)
  }

end
reset_the_line() click to toggle source
#

Colours.reset_the_line

This method will reset the current line. This can then be used in a progress indicator application.

#
# File lib/colours/toplevel_methods/misc.rb, line 205
def self.reset_the_line
  STDOUT.write("\u001b[1000D") # Move to the left by 1000 characters. Aka reset.
  STDOUT.flush # This line will force the output to appear immediately,
end
return_a_unique_array_containing_all_available_colours() click to toggle source
#

Colours.return_a_unique_array_containing_all_available_colours

#
# File lib/colours/toplevel_methods/autogenerate.rb, line 278
def self.return_a_unique_array_containing_all_available_colours
  array = []
  array << YAML.load_file(FILE_HTML_COLOURS).keys                # (1) First the HTML colours
  array << YAML.load_file(FILE_256_COLOURS).keys.map(&:downcase) # (2) Then the basic colours
  array << YAML.load_file(FILE_BASIC_COLOURS)                    # (3) And finally the basic colours
  array.flatten!
  array.uniq!
  array.map!(&:strip)
  array.sort
end
return_italic( show_this_text = 'This must be italic.', make_newline = false ) { || ... } click to toggle source
#

Colours.return_italic

To test this method, try:

Colours.italic('Hello world!')
#
# File lib/colours/toplevel_methods/italic.rb, line 32
def self.return_italic(
    show_this_text = 'This must be italic.', 
    make_newline   = false
  )
  result = "\x1b".dup
  result << '['
  result << ITALIC_CODE
  if block_given?
    # ===================================================================== #
    # Right now we assume that this must be a colour.
    # ===================================================================== #
    result << ";38;2;"
    result << html_colour_to_stringified_rgb_values(yield)
  end
  result << 'm'
  if make_newline
    show_this_text = "#{show_this_text}\n"
  end
  result << show_this_text
  result << REVERT
  result
end
return_main_regex_to_use_for_obtaining_the_full_content(this_colour) click to toggle source
#

Colours.return_main_regex_to_use_for_obtaining_the_full_content

The first regex that is commented out, in the body of this method, was in use until May 2023. It was then replaced with the new regex, which also has an associated test-case, in the test/ subdirectory of the colours gem.

For the current regex see here:

https://rubular.com/r/1gS5KsnGpSjQTN

I was also using a second regex that was slightly incompatible. For legacy reasons it can be seen here: rubular.com/r/sDNQd81MtciMJL

#
# File lib/colours/toplevel_methods/methods_related_to_html_colours.rb, line 55
def self.return_main_regex_to_use_for_obtaining_the_full_content(this_colour)
  # /<#{this_colour}>([\-\{\}\[\]\\\(\)\/a-zA-Z0-9’éúÄäÖöÜüÅαβß&%+−=≡πμ°₁₂₃₄₅₆₇₈₉⁰¹²³⁴⁵⁶⁷⁸⁹⁻!#\*~:;∨"',_\|\n\. ]+)<\/#{this_colour}>/
  # /<#{this_numbered_word}>([-#~≥!\e=><;,→⁻⁺@^„“γαµ_₀₁₂₃₄₅₆₇₈₉²³⁴⁵⁶⁷⁸⁹äöüÄÖÜβß%&:≡°$A-Za-z0-9\n \?\\'\|\(\)\{\}\[\]\"\*\.\+]+)<\/#{this_numbered_word}>/
  /<#{this_colour}>([\n₀₁₂₃₄₅₆₇₈₉⁰¹²³⁴⁵⁶⁷⁸⁹°→⁻⁺≥$@πμγ∨^αβßÅÄäéúÖöÜüa-zA-Z0-9’'"„“~#&%!,;:_+−=≡<>\*\\\/\.\{\}\(\)\|\[\]\?\- ]*?)<\/#{this_colour}>/
end
return_random_rgb() click to toggle source
#

Colours.return_random_rgb

#
# File lib/colours/rgb/rgb.rb, line 283
def self.return_random_rgb
  [random_value?, random_value?, random_value?]
end
return_this_256_colour( id = 9, use_this_text = "Hello world!" ) click to toggle source
#

Colours.return_this_256_colour

The first argument to this method should be a number from 0 to 255.

For example, 255 is also known as “Grey93” - a variant of grey.

It appears to work better if you use print() rather than puts() for whatever is returned here - perhaps due to the leading u001b part.

You can also input the colour variant, such as ‘Grey93’.

Invocation example:

Colours.return_this_256_colour(255, "Hello world in grey!\n")
print Colours.return_this_256_colour(255, (Roebe.block_character*5)+"  Hello world in grey!  "+(Roebe.block_character*5)+" \n")
print Colours.return_this_256_colour('DarkTurquoise', (Roebe.block_character*5)+"  Hello world in DarkTurquoise!  "+(Roebe.block_character*5)+" \n")
#
# File lib/colours/256_colours/support_for_256_colours.rb, line 47
def self.return_this_256_colour(
    id            = 9,
    use_this_text = "Hello world!"
  )
  id = id.to_s.downcase
  if (id !~ /^\d+/) and @dataset_for_the_256_colours and
    @dataset_for_the_256_colours.has_key?(id)
    id = @dataset_for_the_256_colours[id]
  end
  "\u001b[38;5;#{id}m#{use_this_text}#{REVERT}"
end
return_this_text_in_random_colour( show_this_text = '' ) click to toggle source
#

Colours.return_this_text_in_random_colour

Invocation example:

puts Colours.return_this_text_in_random_colour('Hello World!')
#
# File lib/colours/rgb/rgb.rb, line 383
def self.return_this_text_in_random_colour(
    show_this_text = ''
  )
  use_this_colour = ::Colours.random_colour?
  "#{rgb(use_this_colour)}#{show_this_text}#{restore?}"
end
return_this_via_kde_colour_palette( this_text = '', this_colour = 'Pimpinella' ) click to toggle source
#

Colours.return_this_via_kde_colour_palette

To invoke this method, try:

Colours.return_this_via_kde_colour_palette 'Hello world!'
Colours.return_this_via_kde_colour_palette 'Hello world!', :random
Colours.return_this_via_kde_colour_palette 'Hello world!', :plasma_blue
#
# File lib/colours/kde_colour_palette/kde_colour_palette.rb, line 75
def self.return_this_via_kde_colour_palette(
    this_text   = '',
    this_colour = 'Pimpinella'
  )
  use_this_rgb_value_array = []
  case this_colour
  when :random # Pick a random colour in this case.
    this_colour = KDE_COLOUR_PALETTE.keys.sample
  else
    if this_colour.is_a? Symbol
      if this_colour.to_s.include? '_'
        # ================================================================= #
        # In this case, try to convert it.
        # ================================================================= #
        this_colour = this_colour.to_s.split('_').map(&:capitalize).join(' ')
      else
        this_colour = this_colour.to_s.capitalize
      end
    end
  end
  if KDE_COLOUR_PALETTE.has_key? this_colour
    use_this_rgb_value_array = KDE_COLOUR_PALETTE[this_colour][1]
  end
  # ======================================================================= #
  # Finally return the text, in the corresponding colour at hand.
  # ======================================================================= #
  return ::Colours.rgb_value_as_escape_code_string(use_this_rgb_value_array)+
         this_text+
         rev
end
return_underline( show_this_text = 'This must be underline.', make_newline = false, use_this_as_revert_code = REVERT ) click to toggle source
#

Colours.return_underline

The point of this method here is to make a given text (String) appear “underlined”, via ANSI escape sequences. For underline the String that should be used is “u001b[4m”.

This can be tested on the commandline such as via:

echoen "\u001b[4m Underline \u001b[0m"

Usage examples:

puts ' ok | '+Colours.return_underline('Hello world!')+' | ok'
puts ' ok | '+Colours.return_underline('Hello world!') { :slateblue }+' | ok'

In January 2022 the second variant was removed, though. Let’s keep things simple for now - perhaps in the future this may be re-enabled.

#
# File lib/colours/toplevel_methods/underline.rb, line 77
def self.return_underline(
    show_this_text          = 'This must be underline.',
    make_newline            = false,
    use_this_as_revert_code = REVERT
  )
  # ===================================================================== #
  # Build up our main string that codes for underline.
  # ===================================================================== #
  result = "\u001b[#{UNDERLINE_CODE}m".dup
  # if block_given?
  #   # ===================================================================== #
  #   # Right now we assume that this must be a colour if it is supplied
  #   # via a block. However had, in January 2022 I realised that this
  #   # assumption is not always correct, so this was disabled for now.
  #   # At a later moment in time we may reconsider this.
  #   # ===================================================================== #
  #   result << ";38;2;"
  #   colour_replacement = colour_to_rgb_value(yield)
  #   result << colour_replacement
  # end
  # result << 'm'
  if make_newline # Append a newline in this case.
    show_this_text = "#{show_this_text}\n"
  end
  result << show_this_text
  result << use_this_as_revert_code
  return result
end
rev() click to toggle source
#

Colours.rev

We use this method to revert to the old default, that is, the prior state for ANSI colours. It should be equivalent to: “x1b[0m” e. g. REVERT = “x1b[0m” # “x1b[39;49m” <— This here seems to fail for Konsole.underline, though.

An alternative could be DEFAULT_COLOUR.

#
# File lib/colours/toplevel_methods/revert.rb, line 70
def self.rev
  # REVERT # <- This used to be: "\e[0;37m"
  @revert # This is light white. I prefer this colour actually.
end
rgb_print( array = %w( 100 247 63 ), text = 'Hello world!' ) click to toggle source
#

Colours.rgb_print

The first argument to this method should be an Array.

We will print here. If you need a newline appended, you have to do so on your own, by appending a n onto the text variable given to this method - or use Colours.rgb_puts() instead.

Specific usage examples:

Colours.rgb_print ["100", "247", "63"], 'Hello '
Colours.rgb_print ["100", "247", "25"], 'World!'
#
# File lib/colours/rgb/rgb.rb, line 352
def self.rgb_print(
    array = %w( 100 247 63 ),
    text  = 'Hello world!'
  )
  print "#{rgb_value_as_escape_code_string(array)}#{text}#{REVERT}"
end
rgb_puts( array = %w( 100 247 63 ), text = 'Hello world!' ) click to toggle source
#

Colours.rgb_puts

First argument should be an Array.

We will use puts here.

Specific usage examples:

Colours.rgb_puts ["100", "247", "63"], 'Hello '
Colours.rgb_puts ["100", "247", "25"], 'World!'
#
# File lib/colours/rgb/rgb.rb, line 370
def self.rgb_puts(
    array = %w( 100 247 63 ),
    text  = 'Hello world!'
  )
  rgb_print(array, "#{text}\n")
end
rgb_value_as_escape_code_string( array = [ random_value?, random_value?, random_value? ], g = nil, b = nil ) click to toggle source
#

Colours.rgb_value_as_escape_code_string

This method will take a R,G,B value and show us a String representation

#
# File lib/colours/rgb/rgb.rb, line 481
def self.rgb_value_as_escape_code_string(
    array = [
      random_value?,
      random_value?,
      random_value?
    ],
    g = nil,
    b = nil
  )
  if array.is_a? Symbol
    array = array.to_s
  end
  if array.is_a?(Array) and (array.size == 3)
    r = array[0]
    g = array[1]
    b = array[2]
  elsif array.is_a?(String) and g.nil? and b.nil?
    # ======================================================================= #
    # In this case we will assume a HTML colour. We thus have to
    # determine its rgb value.
    # ======================================================================= #
    if ::Colours.is_this_html_colour_included?(array)
      set_last_colour_used(array)
      r, g, b = ::Colours.convert_this_html_colour_into_an_array_of_rgb_values(array)
    else
      puts 'The input is not a HTML colour:'
      pp array
    end
  end
  # =========================================================================== #
  # The String that we build up in this method will have the ANSI escape
  # code on the left side.
  # =========================================================================== #
  return "#{left?}#{r};#{g};#{b}m"
end
rparse(i = '') click to toggle source
#

Colours.rparse

This method will return a string; the method eparse will output that (colourized) String.

#
# File lib/colours/eparse/eparse.rb, line 53
def self.rparse(i = '')
  _ = i.to_s # We require a String.
  split_at = ':' # <- Split at this character.
  # ======================================================================== #
  # If the input does not include a ':' but it does include a '#', then
  # we will use that character instead.
  #
  # However had, as of Jun 2017, I have disabled that check. Now '#' will
  # always overrule. My reasoning now is that '#' is more important than
  # ':', if it is part of the input-string.
  # ======================================================================== #
  split_at = '#' if _.include? '#'
  first_colour  = ::Colours::Eparse::FIRST_COLOUR
  second_colour = ::Colours::Eparse::SECOND_COLOUR
  if i.include? split_at
    splitted = _.split(split_at)
    _ = first_colour+
        splitted.first+
        split_at+
        second_colour+
        splitted[1..-1].join(split_at).dup
    _ << REVERT
  elsif i.include? ' '
    split_at = ' '
    splitted = _.split(/ /)
    index = splitted.find_index {|e| ! e.empty? }
    _ = first_colour+splitted[0..index].join(' ')+split_at+
        second_colour+splitted[index+1..-1].join(' ').dup
    _ << REVERT
  end
  return _
end
sanitize_line(entry) click to toggle source
#

Colours.sanitize_line

This method will replace one line with the proper R,G,B valid entries.

#
# File lib/colours/toplevel_methods/misc.rb, line 61
def self.sanitize_line(entry)
  all_potential_matches = entry.scan(/<(\w+)>/).flatten
  all_potential_matches.each {|substring|
    entry.gsub!(/<\/>/, rev)
    entry.gsub!(/<#{substring}>/, rgb_format(substring))
  }
  begin
    require 'roebe/modules/remove_html.rb'
  rescue LoadError; end
  if Object.const_defined?(:Roebe) and
     Roebe.respond_to?(:remove_html)
    entry = Roebe.remove_html[entry]
  end
  return entry
end
sargument( i = '', make_newline = false ) click to toggle source
#

Colours.sargument

Invocation example:

Colours.sargument('Hello world!')
#
# File lib/colours/colour_methods/colour_methods.rb, line 159
def self.sargument(
    i            = '',
    make_newline = false
  )
  if make_newline
    i = "#{i}#{N}"
  end
  if @use_colours
    if @use_html_colours
      i = SupportForHTMLColours.send(@colour_table[__method__.to_sym], i)
    elsif @use_256_colours
      use_this_colour = map_this_symbol_to_that_256_colour(@colour_table[__method__.to_sym])
      i = SupportFor256Colours.send(use_this_colour, i)
    else
      i = "#{corresponding_colour?(@colour_table[__method__.to_sym])}"\
          "#{i}"\
          "#{rev}"
    end
  end
  i
end
scomments( i = '', make_newline = false ) click to toggle source
#

Colours.scomments

Invocation example:

Colours.scomments('Hello world!')
#
# File lib/colours/colour_methods/colour_methods.rb, line 596
def self.scomments(
    i            = '',
    make_newline = false
  )
  if @use_colours
    if @use_html_colours
      i = SupportForHTMLColours.send(@colour_table[__method__.to_sym], i)
    elsif @use_256_colours
      use_this_colour = map_this_symbol_to_that_256_colour(@colour_table[__method__.to_sym])
      i = SupportFor256Colours.send(use_this_colour, i)
    else
      i = "#{corresponding_colour?(@colour_table[__method__.to_sym])}"\
          "#{i}"\
          "#{rev}"
    end
  end
  i
end
scomments?() click to toggle source
#

Colours.scomments?

This method will usually return :grey.

#
# File lib/colours/colour_methods/colour_methods.rb, line 627
def self.scomments?
  colour_table?[:scomments]
end
sdir( i = '', make_newline = false ) click to toggle source
#

Colours.sdir

Invocation example:

puts Colours.sdir('Hello world!')
#
# File lib/colours/colour_methods/colour_methods.rb, line 112
def self.sdir(
    i            = '',
    make_newline = false
  )
  if make_newline
    i = "#{i}#{N}"
  end
  if @use_colours
    if @use_html_colours
      i = SupportForHTMLColours.send(@colour_table[__method__.to_sym], i)
    elsif @use_256_colours
      use_this_colour = map_this_symbol_to_that_256_colour(@colour_table[__method__.to_sym])  
      i = SupportFor256Colours.send(use_this_colour, i)
    else
      i = "#{corresponding_colour?(@colour_table[__method__.to_sym])}"\
          "#{i}"\
          "#{rev}"
    end
  end
  i
end
set_colour_table( i = :new_colours ) click to toggle source
#

Colours.set_colour_table

This method can be used to modify the instance variable @colour_table.

The input to this method should be a Hash. It can also be a Symbol, in which case we will try to find a Hash that corresponds to that Symbol.

If in doubt, pass in a Hash though.

#
# File lib/colours/colour_table/colour_table.rb, line 185
def self.set_colour_table(
    i = :new_colours
  )
  case i
  when :new_colours,
       :new_colour_table,
       :default
    i = HASH_NEW_COLOURS
  end
  # ======================================================================= #
  # Note that we must ensure that all the necessary keys are there
  # in the given input. If this is not the case, then we will
  # determine which entries are missing, and assign them from the
  # instance variable @colour_table.
  # ======================================================================= #
  missing_entries = (
    i.keys - @colour_table.keys
  ).flatten
  unless missing_entries.empty?
    # ===================================================================== #
    # Push them onto i in this case.
    # ===================================================================== #
    missing_entries.each {|this_key|
      if i.has_key? this_key
        # All fine, pass through in this case.
      else
        add_this = missing_entries[this_key]
        i[key] = add_this

      end
    }
  end
  @colour_table = i
end
set_commandline(i = ARGV) click to toggle source
#

Colours.set_commandline

#
# File lib/colours/commandline/commandline.rb, line 17
def self.set_commandline(i = ARGV)
  @commandline = [i].flatten.compact
end
set_last_colour_used(i) click to toggle source
#

Colours.set_last_colour_used

#
# File lib/colours/toplevel_methods/set_last_colour_used.rb, line 28
def self.set_last_colour_used(i)
  @last_colour_used = i
end
set_revert(i = :default) click to toggle source
#

Colours.set_revert

#
# File lib/colours/toplevel_methods/revert.rb, line 50
def self.set_revert(i = :default)
  case i
  # ======================================================================= #
  # === :default
  # ======================================================================= #
  when :default
    i = REVERT
  end
  @revert = i
end
sfancy( i = '', make_newline = false ) click to toggle source
#

Colours.sfancy

Invocation example:

Colours.sfancy('Hello world!')
#
# File lib/colours/colour_methods/colour_methods.rb, line 529
def self.sfancy(
    i            = '',
    make_newline = false
  )
  if @use_colours
    if @use_html_colours
      i = SupportForHTMLColours.send(
        map_this_symbol_to_that_html_colour(@colour_table[__method__.to_sym]), i
      )
    elsif @use_256_colours
      use_this_colour = map_this_symbol_to_that_256_colour(@colour_table[__method__.to_sym])
      i = SupportFor256Colours.send(use_this_colour, i)
    else
      i = "#{corresponding_colour?(@colour_table[__method__.to_sym])}"\
          "#{i}"\
          "#{rev}"
    end
  end
  i
end
sfile( i = '', make_newline = false ) click to toggle source
#

Colours.sfile

This method can be explicitely used to colour files, such as ‘/opt/foobar.rb’.

Invocation examples:

Colours.sfile('/opt/foobar.rb')
Colours.sfile('/tmp/test.md')
Colours.sfile('Hello world!')
#
# File lib/colours/colour_methods/colour_methods.rb, line 217
def self.sfile(
    i            = '',
    make_newline = false
  )
  if @use_colours
    if @use_html_colours
      i = SupportForHTMLColours.send(
        map_this_symbol_to_that_html_colour(@colour_table[__method__.to_sym]), i
      )
    elsif @use_256_colours
      use_this_colour = map_this_symbol_to_that_256_colour(@colour_table[__method__.to_sym])
      i = SupportFor256Colours.send(use_this_colour, i)
    else
      i = "#{corresponding_colour?(@colour_table[__method__.to_sym])}"\
          "#{i}"\
          "#{rev}"
    end
  end
  i
end
show_256_colour_cube() click to toggle source
#

Colours.show_256_colour_cube

This will show the 256-colours cube. Colours 16-231 are a 6x6x6 color cube.

#
# File lib/colours/256_colours/support_for_256_colours.rb, line 149
def self.show_256_colour_cube
  puts 'Color cube, 6x6x6 blocks:'
  0.upto(5) {|green|
    0.upto(5) {|red|
      0.upto(5) {|blue|
        colour = 16 + (red * 36) + (green * 6) + blue
        print "\x1b[48;5;#{colour}m  "
      }
      print "\x1b[0m "
    }
    puts
  }
end
show_all_256_colours() { || ... } click to toggle source
#

Colours.show_all_256_colours

#
# File lib/colours/256_colours/support_for_256_colours.rb, line 128
def self.show_all_256_colours
  yielded = nil
  if block_given?
    yielded = yield
  end
  0.upto(255).each {|this_number|
    result = this_number.to_s.rjust(4)+' '+
             return_this_256_colour(this_number).to_s.dup
    if yielded and yielded == :newline
      result << "\n"
    end
    print result
  }
end
show_basic_colour_palette() click to toggle source
#

Colours.show_basic_colour_palette

This will show a colour palette on the commandline.

#
# File lib/colours/toplevel_methods/show_basic_colour_palette.rb, line 19
def self.show_basic_colour_palette
  e
  MAIN_COLOURS.reject {|e| e == :black }.each { |entry|
    make_colour(entry) # make_colour() is defined in this file here.
  }
  cliner
  SECONDARY_COLOURS.each { |entry|
    make_colour(entry)
  }
  e
end
show_help() click to toggle source
#

Colours.show_help (help tag)

#
# File lib/colours/commandline/commandline.rb, line 43
def self.show_help
  e
  e 'This menu supports the following commands:'
  e
  eparse '  file?               # read in from the default test file'
  eparse '  html_colours        # show all html colours'
  eparse '  open                # open this file here in your editor'
  eparse '  --version?          # report the current version of '\
         'the colours gem'
  eparse '  --base-dir?         # show the project base directory '\
         'of the Colours namespace'
  eparse '  --show-html-colours # show the available HTML colours'
  e
end
show_html_colours() click to toggle source
#

Colours.show_html_colours

#
# File lib/colours/html_colours/html_colours.rb, line 261
def self.show_html_colours
  ::Colours::HtmlColours.show_html_colours
end
show_the_colour_table() click to toggle source
#

Colours.show_the_colour_table

This will simply pretty-print the current colour table.

#
# File lib/colours/colour_table/colour_table.rb, line 233
def self.show_the_colour_table
  pp @colour_table
end
show_the_version() click to toggle source
#

Colours.show_the_version

Invocation example:

colours --version?
#
# File lib/colours/commandline/commandline.rb, line 36
def self.show_the_version
  e steelblue(VERSION)
end
shuffle() click to toggle source
#

Colours.shuffle

Shuffle the above table. The available colours to take here will be from the HtmlColours namespace.

#
# File lib/colours/colour_table/colour_table.rb, line 243
def self.shuffle
  # ======================================================================= #
  # Point to the html "table" to use.
  # ======================================================================= #
  _ = ::Colours::HtmlColours.all?.shuffle
  @colour_table = {
    simp:      _.shift,
    sdir:      _.shift,
    sfile:     _.shift,
    swarn:     _.shift,
    sfancy:    _.shift,
    sargument: _.shift,
    ssymlink:  _.shift
  }
end
simple_colours_test() click to toggle source
#

Colours.simple_colours_test

This method purposely tests only the basic parts for colours-related output onto the terminal.

#
# File lib/colours/testing/testing.rb, line 22
def self.simple_colours_test
  show_basic_colour_palette
end
simportant( i = '', make_newline = false ) click to toggle source
========================================================================= #
=== Colours.simportant

This method is the one to denote “important” text components.

Invocation examples:

  Colours.simportant('Hello world!')
  Colours.simportant('yo there')

========================================================================= #
# File lib/colours/colour_methods/colour_methods.rb, line 315
def self.simportant(
    i            = '',
    make_newline = false
  )
  if @use_colours
    if @use_html_colours
      i = SupportForHTMLColours.send(
        map_this_symbol_to_that_html_colour(@colour_table[__method__.to_sym]), i
      )
    elsif @use_256_colours
      use_this_colour = map_this_symbol_to_that_256_colour(@colour_table[__method__.to_sym])
      i = SupportFor256Colours.send(use_this_colour, i)
    else
      i = "#{corresponding_colour?(@colour_table[__method__.to_sym])}"\
          "#{i}"\
          "#{rev}"
    end
  end
  i
end
snormal( i = '', make_newline = false ) click to toggle source
#

Colours.snormal

Invocation example:

Colours.snormal('Hello world!')
#
# File lib/colours/colour_methods/colour_methods.rb, line 263
def self.snormal(
    i            = '',
    make_newline = false
  )
  if @use_colours
    if @use_html_colours
      i = SupportForHTMLColours.send(
        map_this_symbol_to_that_html_colour(@colour_table[__method__.to_sym]), i
      )
    elsif @use_256_colours
      use_this_colour = map_this_symbol_to_that_256_colour(@colour_table[__method__.to_sym])
      i = SupportFor256Colours.send(use_this_colour, i)
    else
      i = "#{corresponding_colour?(@colour_table[__method__.to_sym])}"\
          "#{i}"\
          "#{rev}"
    end
  end
  i
end
swarn( i = '', make_newline = false ) click to toggle source
#

Colours.swarn

Invocation example:

Colours.swarn('Hello world!')
#
# File lib/colours/colour_methods/colour_methods.rb, line 385
def self.swarn(
    i            = '',
    make_newline = false
  )
  if @use_colours
    if @use_html_colours
      i = SupportForHTMLColours.send(
        map_this_symbol_to_that_html_colour(@colour_table[__method__.to_sym]), i
      )
    elsif @use_256_colours
      use_this_colour = map_this_symbol_to_that_256_colour(@colour_table[__method__.to_sym])
      i = SupportFor256Colours.send(use_this_colour, i)
    else
      i = "#{corresponding_colour?(@colour_table[__method__.to_sym])}"\
          "#{i}"\
          "#{rev}"
    end
  end
  i
end
test() click to toggle source
#

Colours.test

This class-method can be used to test the Colours module.

It will be called from the test.rb file, in order to test all components of the Colours module.

To invoke it, do:

Colours.test
#
# File lib/colours/testing/testing.rb, line 39
def self.test
  require 'colours/basic_colours/basic_colours.rb'
  require 'colours/colour_table/colour_table.rb'
  cliner
  show_basic_colour_palette
  cliner
  e red('Hello ')+cyan('World!')
  e 'Hi '+Colours.red+'there.'+rev
  e 'Hi '+Colours.cyan+'there.'+rev
  e 'Hi '+Colours::BasicColours.bold_white+'there.'+rev
  e 'Hi '+Colours.pink+'there.'+rev
  e 'Hi '+Colours.brown+'there.'+rev
  cliner
  e CYAN+'Hi there.'
  e BWHITE+'Hi there.'+BBLUE+' Yo there.'+rev
  e sfancy('yo')+simp(' there')
  disable_colours(true)
  e sfancy('yo')+simp(' there')
  enable_colours(true)
  e sfancy('yo')+simp(' there')
  e rgb_to_hex('155255255')
  e col '/Depot/Audio'
  e col '/Depot/Audio/Westbam_Sunshine.mp3'
  e rev+'This is '+simp('elegant => simportant()')+'.'
  e rev+'This is '+sfancy('elegant => sfancy()')+'.'
  e rev+'This is '+sdir('elegant => sdir()')+'.'
  e rev+'This is '+sfile('elegant => sfancy()')+'.'
  e rev+'This is '+swarn('elegant => swarn()')+'.'
  e rev+'This is '+ssym('elegant => ssym()')+'.'
  ecomment 'An this # could be a comment.'
  e
  e 'Changing colour codes now. We should see different colours '+
    'when compared to the above.'
  e
  ::Colours.update_the_colour_codes_with
  e rev+'This is '+simportant('elegant => simportant()')+'.'
  e rev+'This is '+sfancy('elegant => sfancy()')+'.'
  e rev+'This is '+sdir('elegant => sdir()')+'.'
  e rev+'This is '+sfile('elegant => sfancy()')+'.'
  e rev+'This is '+swarn('elegant => swarn()')+'.'
  e rev+'This is '+ssym('elegant => ssym()')+'.'
  e 'Do we use colours? '+use_colours?.to_s
  e cyan+' ==> Hi there.'
  e red+' ==> Hi there.'
  e green+' ==> Hi there.'
  e brown+' ==> Hi there.'
  e blue+' ==> Hi there.'
  e teal+' ==> Hi there.'
  e white+' ==> Hi there.'
  e grey+' ==> Hi there.'
  e lightblue+' ==> Hi there.'+red()+' yo'
  e RED+'This is red galore.'
  e 'right?'+::Colours.rev
  e BLUE+'This is blue now.'
  e 'right?'+rev
  e 'Hi there - this should be white.'
  # html_colours?
  p main_colours
  main_colours.each {|entry|
    send(entry, 'test')
  }
  e 'yo this should '+pink('be pink.')
  puts CFANCY+' Hi there.'
  puts CIMPORTANT+' Hi there.'
  # Next, we will disable the colours.
  disable_colours(true)
  # The following ones have a newline.
  e rev+'This is '+simportant('elegant => simportant().',true)
  e rev+'This is '+sfancy('elegant => sfancy().',true)
  e rev+'This is '+sdir('elegant => sdir().',true)
  e rev+'This is '+sfile('elegant => sfancy().',true)
  ::Colours.enable_colours(true)
  e rev+'This is '+simportant('elegant => simportant()')+'.'
  e rev+'This is '+sfancy('elegant => sfancy()')+'.'
  e rev+'This is '+sdir('elegant => sdir()')+'.'
  e rev+'This is '+sfile('elegant => sfancy()')+'.'; e
  e 'Next, trying to underline:'
  underline 'Hi there'
  e 'Next trying eparse:'
  eparse 'Joe: Hey Tim, how do you do?'
  eparse 'Tim: Really fine. How about you?'
  eparse '   Joe: ok man let us proceed'
  eparse '  [name of character here] # show when this character last logged in'
  e
  e 'Next some tests with col():'
  e
  e '  '+col('/Depot/Audio/AVAILABLE_SONGS').to_s
  e '  '+col('/Depot/Audio').to_s
  e
  cliner
  e 'Now testing Colours.red("foobar"):'
  e red('foobar')
  e 'Next, we test Colours.enable() and Colours.disable()'
  disable
  e 'Colours.disable()'
  e rev+'This is '+simportant('elegant => simportant()')+'.'
  e 'Colours.enable()'
  enable
  e rev+'This is '+simportant('elegant => simportant()')+'.'
  e rev+'The colour for symlinks is: '+simportant('Colours.colour_for_symlinks')
  pp colour_for_symlinks
  e rev+'A classical Hello World! example, and the colour-code for it.'
  efancy 'Hello World!'
  pp sfancy('Hello World!')
  e 'Next removing some escape sequences:'
  e
  e remove_escape_sequences("  \e[1;31mhello world\e[0;0m # <-- "+
    "This here is not coloured and it also does not have "+
    "escape-sequences either.")
  e
  e 'Next testing whether Colours.yellow() works:'
  e
  e "  hello #{Colours.yellow('world!')}#{rev}"
  e
  e 'Next testing Colours.eparse():'
  e
  eparse '  hello # world!'
  e
  e 'Next testing Colours.ecomment():'
  e
  ecomment '  hello # world!'
  e
end
underline( i = '', make_newline = false, &block ) click to toggle source
#

Colours.underline

This method will “puts” the result of applying underline to a string, on the console/terminal. If you wish to do the output on your own then you have to use the method Colours.return_underline or its alias called Colours.string_underline.

To test this, try:

Colours.underline('Hello world!')
#
# File lib/colours/toplevel_methods/underline.rb, line 40
def self.underline(
    i            = '', 
    make_newline = false,
    &block
  )
  e return_underline(i, make_newline, &block)
end
update_the_colour_codes_with(i = HASH_NEW_COLOURS) click to toggle source
#

Colours.update_the_colour_codes_with (update tag)

#
# File lib/colours/colour_table/colour_table.rb, line 40
def self.update_the_colour_codes_with(i = HASH_NEW_COLOURS)
  @colour_table.update(i)
end
use_colours=( new_value = true ) click to toggle source
#

Colours.use_colours=

Determine whether we will use colours or whether we will not.

The first input argument to this method should be a Bool, such as true or false.

#
# File lib/colours/toplevel_methods/use_colours.rb, line 101
def self.use_colours=(
    new_value = true
  )
  @use_colours = new_value
end
use_colours?() click to toggle source
#

Colours.use_colours?

Use this method to find out whether we wish to use colours or whether we do not.

#
# File lib/colours/toplevel_methods/use_colours.rb, line 36
def self.use_colours?
  @use_colours
end
use_html_colours?() click to toggle source
#

Colours.use_html_colours?

Query whether we will use the HTML colours or whether we will not.

#
# File lib/colours/toplevel_methods/use_colours.rb, line 54
def self.use_html_colours?
  @use_html_colours
end
use_new_colour_table() click to toggle source
#

Colours.use_new_colour_table

#
# File lib/colours/colour_table/colour_table.rb, line 224
def self.use_new_colour_table
  set_colour_table(:new_colour_table)
end
write_this_in_256_colours( this_text = "Hello world!\n", id = rand(256), &block ) click to toggle source
#

Colours.write_this_in_256_colours

Similar to the other write method, but has the arguments reversed.

#
# File lib/colours/256_colours/support_for_256_colours.rb, line 64
def self.write_this_in_256_colours(
    this_text = "Hello world!\n",
    id        = rand(256),
    &block
  )
  display_this_256_colour(id, this_text, &block)
end
write_this_in_random_colour( i = '' ) click to toggle source
#

Colours.write_this_in_random_colour

Usage example:

Colours.write_this_in_random_colour 'hi there'
#
# File lib/colours/rgb/rgb.rb, line 396
def self.write_this_in_random_colour(
    i = ''
  )
  e return_this_text_in_random_colour(i)
end
write_this_via_kde_colour_palette( this_text = '', this_colour = 'Pimpinella', append_newline = true ) click to toggle source
#

Colours.write_this_via_kde_colour_palette

To invoke this method, try any of the following:

Colours.write_this_via_kde_colour_palette 'Hello world!'
Colours.write_this_via_kde_colour_palette 'Hello world!', :random
Colours.write_this_via_kde_colour_palette 'Hello world!', :plasma_blue
#
# File lib/colours/kde_colour_palette/kde_colour_palette.rb, line 116
def self.write_this_via_kde_colour_palette(
    this_text      = '',
    this_colour    = 'Pimpinella',
    append_newline = true
  )
  result = ::Colours.return_this_via_kde_colour_palette(this_text, this_colour)
  if append_newline
    result << "#{N}"
  end
  print result
end

Public Instance Methods

all_html_colours()
argument( i = '', make_newline = false )
Alias for: sargument
assign_new_colour_codes( i = HASH_NEW_COLOURS )
available_html_colours?() click to toggle source
#

available_html_colours?

#
# File lib/colours/html_colours/html_colours.rb, line 344
def available_html_colours?
   Colours.available_html_colours?
end
Also aliased as: html_colours?, html_colours, all_html_colours, return_all_html_colours, colours?, colours, registered_colours?, html_colours?, html_colours, all_html_colours, return_all_html_colours, colours?, colours, registered_colours?
b?()
Alias for: random_value?
beautiful(i)
beautify(i)
build_this_rgb_string( array = [ random_value?, random_value?, random_value? ], g = nil, b = nil )
check_against_menu(i = nil)
Alias for: menu
ci( i = N, append_newline = true )
Alias for: e
cif(i) click to toggle source
#

cif

This is efancy, but we won’t use newlines.

#
# File lib/colours/colour_methods/colour_methods.rb, line 584
def cif(i)
  efancy(i, false)
end
Also aliased as: ff
cii( i = '', make_newline = false )
Alias for: eimportant
ciif(i) click to toggle source
#

ciif

#
# File lib/colours/colour_methods/colour_methods.rb, line 352
def ciif(i)
  eimportant(i, false)
end
colour_to_rgb_value( array = [ random_value?, random_value?, random_value? ], g = nil, b = nil )
colours()
colours?()
comment(i = '')
Alias for: scomments
convert(i)
convert_this_rgb_value_to_that_hexadecimal_representation( r, g = nil, b = nil ) click to toggle source
#

convert_this_rgb_value_to_that_hexadecimal_representation

#
# File lib/colours/rgb/rgb.rb, line 316
def convert_this_rgb_value_to_that_hexadecimal_representation(
    r, g = nil, b = nil
  )
  Colours.convert_this_rgb_value_to_that_hexadecimal_representation(r, g, b)
end
Also aliased as: rgb_to_hex, to_hex, rgb_to_hex, to_hex, return_hexvalue_of_this_colour
corresponding_colour?(i)
default_colour(i = '') click to toggle source
#

default_colour

#
# File lib/colours/colour_methods/colour_methods.rb, line 100
def default_colour(i = '')
  ::Colours.default_colour(i)
end
display_all_colours()
Alias for: show_html_colours
e( i = N, append_newline = true ) click to toggle source
#

e (e tag)

This is just a wrapper towards the above method called Colours.e()

If the second argument ‘make_newline` is true then we will append a newline. This is the default behaviour.

This method just delegates to the module method Colours.e()

#
# File lib/colours/toplevel_methods/e.rb, line 54
def e(
    i              = N,
    append_newline = true
  ) # This is the main point of Colours.
  ::Colours.e(i, append_newline) # Point towards the class method of e().
end
Also aliased as: ci
eargument( i = '', make_newline = false ) click to toggle source
#

eargument

The various simple colourize methods.

#
# File lib/colours/colour_methods/colour_methods.rb, line 197
def eargument(
    i            = '',
    make_newline = false
  )
  e ::Colours.sargument(i, make_newline)
end
ecomment( i, optional_split_at_this_character = ' click to toggle source
#

ecomment

Just a wrapper over the Colours.ecomment() functionality.

#
# File lib/colours/colour_methods/colour_methods.rb, line 636
def ecomment(
    i,
    optional_split_at_this_character = '#'
  )
  ::Colours.ecomment(i, optional_split_at_this_character)
end
edefault_colour( i = '', make_newline = false ) click to toggle source
#

edir

#
# File lib/colours/colour_methods/colour_methods.rb, line 90
def edefault_colour(
    i            = '',
    make_newline = false
  )
  e ::Colours.default_colour(i, make_newline)
end
edir( i = '', make_newline = false ) click to toggle source
#

edir

#
# File lib/colours/colour_methods/colour_methods.rb, line 137
def edir(
    i            = '',
    make_newline = false
  )
  e ::Colours.sdir(i, make_newline)
end
ef(i) click to toggle source
#

ef

#
# File lib/colours/toplevel_methods/e.rb, line 18
def ef(i)
  e(i, false) # The variant without newlines.
end
efancy( i = '', make_newline = false ) click to toggle source
#

efancy

#
# File lib/colours/colour_methods/colour_methods.rb, line 565
def efancy(
    i            = '',
    make_newline = false
  )
  ::Colours.efancy(i, make_newline)
end
Also aliased as: f
efile( i = '', make_newline = false ) click to toggle source
#

efile

#
# File lib/colours/colour_methods/colour_methods.rb, line 248
def efile(
    i            = '',
    make_newline = false
  )
  e sfile(i, make_newline)
end
eimp( i = '', make_newline = false )
Alias for: eimportant
eimportant( i = '', make_newline = false ) click to toggle source
#

eimportant

#
# File lib/colours/colour_methods/colour_methods.rb, line 369
def eimportant(
    i            = '',
    make_newline = false
  )
  ::Colours.eimp(i, make_newline)
end
Also aliased as: eimp, cii
enormal( i = '', make_newline = false ) click to toggle source
#

enormal

#
# File lib/colours/colour_methods/colour_methods.rb, line 297
def enormal(
    i            = '',
    make_newline = false
  )
  e snormal(i, make_newline)
end
eparse(i = '') click to toggle source
#

eparse (eparse tag)

Input to this method could be like this:

eparse 'Foo: bla'
eparse 'Foo: '+bla
#
# File lib/colours/eparse/eparse.rb, line 106
def eparse(i = '')
  ::Colours.eparse(i)
end
ewarn( i = '', make_newline = false ) click to toggle source
#

ewarn

#
# File lib/colours/colour_methods/colour_methods.rb, line 429
def ewarn(
    i            = '',
    make_newline = false
  )
  ::Colours.ewarn(i, make_newline)
end
f( i = '', make_newline = false )
Alias for: efancy
ff(i)
Alias for: cif
g?()
Alias for: random_value?
html_colours()
html_colours?()
is_this_a_256_colour?(i) click to toggle source
#

is_this_a_256_colour?

#
# File lib/colours/256_colours/support_for_256_colours.rb, line 182
def is_this_a_256_colour?(i)
  ::Colours.is_this_a_256_colour?(i)
end
italic( i = '', make_newline = false ) click to toggle source
#

italic

#
# File lib/colours/toplevel_methods/italic.rb, line 77
def italic(
    i            = '',
    make_newline = false
  )
  ::Colours.italic(i, make_newline)
end
last_colour_used?() click to toggle source
#

last_colour_used?

Tell us which colour was used last.

#
# File lib/colours/toplevel_methods/set_last_colour_used.rb, line 21
def last_colour_used?
  @last_colour_used.to_s # Always required a string.
end
left?() click to toggle source
#

left?

#
# File lib/colours/constants/misc.rb, line 128
def left?
  Colours.left?
end
main_colours() click to toggle source
#

main_colours

This will return an Array with the symbols such as :black, :red etc..

#
# File lib/colours/constants/hash_simple_colours.rb, line 71
def main_colours
  ::Colours.available_main_colours?
end
map_colour_to_constant(i)
map_symbol_to_colour(i)
map_symbol_to_corresponding_colour(i) click to toggle source
#

map_symbol_to_corresponding_colour

This maps a colour (string) to the respective constant.

#
# File lib/colours/map_symbol_to_corresponding_colour/map_symbol_to_corresponding_colour.rb, line 215
def map_symbol_to_corresponding_colour(i)
  ::Colours.map_symbol_to_corresponding_colour(i)
end
map_this_symbol(i)
menu(i = nil) click to toggle source
#

menu (menu tag)

#
Also aliased as: check_against_menu
open_this_file( shall_we_exit = false ) click to toggle source
#

Colours.open_this_file

#
# File lib/colours/toplevel_methods/open_this_file.rb, line 14
def open_this_file(
    shall_we_exit = false
  )
  case shall_we_exit
  when :then_exit
    shall_we_exit = true
  end
  _ = "bluefish #{__FILE__}"
  esystem(_)
  exit if shall_we_exit
end
r?()
Alias for: random_value?
random()
Alias for: random_colour?
random_colour()
Alias for: random_colour?
random_colour?() click to toggle source
#

random_colour?

#
# File lib/colours/html_colours/html_colours.rb, line 379
def random_colour?
  return Colours.random_html_colour
end
Also aliased as: random_colour, random, sample, random_html_colour, return_random_html_colour, return_random_colour, random_colour, random, sample, random_html_colour, return_random_html_colour
random_html_colour()
Alias for: random_colour?
random_html_colour?()
Alias for: random_html_colour
random_value()
Alias for: random_value?
random_value?() click to toggle source
#

random_value

We will obtain a random value between 0 and 255, hence why we will use rand(256).

#
# File lib/colours/toplevel_methods/random_value.rb, line 29
def random_value?
  Colours.random_value?
end
Also aliased as: random_value, rvalue, r?, g?, b?, rvalue, random_value, r?, g?, b?
registered_colours?()
restore?(i = '')
Also aliased as: revert, rev?
Alias for: rev
return_all_html_colours()
return_hexvalue_of_this_colour( r, g = nil, b = nil )
return_html_colour?()
Alias for: random_html_colour
return_random_colour()
Alias for: random_colour?
return_random_html_colour()
Alias for: random_html_colour
return_random_rgb() click to toggle source
#

return_random_rgb

#
# File lib/colours/rgb/rgb.rb, line 290
def return_random_rgb
  Colours.return_random_rgb
end
Also aliased as: return_rgb_as_array, return_rgb_as_array
return_rgb_as_array()
Alias for: return_random_rgb
rev(i = '') click to toggle source
#

rev

Use this method to “revert” to the old default colour again, by delegating towards the Colours.rev() method defined above.

From this point on, we use methods that can be toggled.

#
# File lib/colours/toplevel_methods/revert.rb, line 85
def rev(i = '')
  ::Colours.rev # This will refer to the Colours.rev() module method.
end
Also aliased as: revert, revert?, restore?, revert
rev?(i = '')
Alias for: restore?
revert(i = '')
Alias for: rev
revert?(i = '')
Alias for: rev
rgb( array = [ random_value?, random_value?, random_value? ], g = nil, b = nil )
rgb_as_string( array = [ random_value?, random_value?, random_value? ], g = nil, b = nil )
rgb_format( array = [ random_value?, random_value?, random_value? ], g = nil, b = nil )
rgb_to_hex( r, g = nil, b = nil )
rgb_value_as_escape_code_string( array = [ random_value?, random_value?, random_value? ], g = nil, b = nil ) click to toggle source
#

rgb_value_as_escape_code_string

#
# File lib/colours/rgb/rgb.rb, line 297
def rgb_value_as_escape_code_string(
    array = [
      random_value?,
      random_value?,
      random_value?
    ],
    g = nil,
    b = nil
  )
end
Also aliased as: build_this_rgb_string, rgb_value_as_string, rgb, rgb_format, rgb_as_string, colour_to_rgb_value, build_this_rgb_string, rgb_value_as_string, rgb, rgb_format, rgb_as_string, colour_to_rgb_value
rgb_value_as_string( array = [ random_value?, random_value?, random_value? ], g = nil, b = nil )
rvalue()
Alias for: random_value?
sample()
Alias for: random_colour?
sarg( i = '', make_newline = false )
Alias for: sargument
sargument( i = '', make_newline = false ) click to toggle source
#

sargument

#
# File lib/colours/colour_methods/colour_methods.rb, line 185
def sargument(
    i = '',
    make_newline = false
  )
  ::Colours.sargument(i, make_newline)
end
Also aliased as: argument, sarg, sarg
scomment(i = '')
Alias for: scomments
scomments(i = '') click to toggle source
#

scomments

#
# File lib/colours/colour_methods/colour_methods.rb, line 618
def scomments(i = '')
  ::Colours.scomments(i) # Delegate towards Colours.scomments? here.
end
Also aliased as: comment, scomment
sdir(i = '') click to toggle source
#

sdir

#
# File lib/colours/colour_methods/colour_methods.rb, line 147
def sdir(i = '')
  ::Colours::sdir(i)
end
sfancy(i = '') click to toggle source
#

sfancy

#
# File lib/colours/colour_methods/colour_methods.rb, line 575
def sfancy(i = '')
  ::Colours.sfancy(i)
end
sfile(i = '') click to toggle source
#

sfile

#
# File lib/colours/colour_methods/colour_methods.rb, line 241
def sfile(i = '')
  ::Colours.sfile(i)
end
show_all_colours()
Alias for: show_html_colours
show_colours()
Alias for: show_html_colours
show_html_colours() click to toggle source
#

show_html_colours

#
# File lib/colours/html_colours/html_colours.rb, line 271
def show_html_colours
  ::Colours.show_html_colours
end
si( i = '', make_newline = false )
Alias for: simportant
simp( i = '', make_newline = false )
Alias for: simportant
simportant( i = '', make_newline = false ) click to toggle source
#

simportant

Delegate towards Colours.simportant() here.

#
# File lib/colours/colour_methods/colour_methods.rb, line 341
def simportant(
    i            = '',
    make_newline = false
  )
  ::Colours.simportant(i, make_newline)
end
Also aliased as: simp, simp, si
snormal( i = '', make_newline = false ) click to toggle source
#

snormal

#
# File lib/colours/colour_methods/colour_methods.rb, line 287
def snormal(
    i            = '',
    make_newline = false
  )
  ::Colours.snormal(i, make_newline)
end
ssym(i = '')
Alias for: ssymlink
swarn( i = '', make_newline = false ) click to toggle source
#

swarn

#
# File lib/colours/colour_methods/colour_methods.rb, line 409
def swarn(
    i            = '',
    make_newline = false
  )
  ::Colours.swarn(i, make_newline)
end
sym(i = '')
Alias for: ssymlink
test()
Alias for: show_html_colours
to_hex( r, g = nil, b = nil )
translate(i)
underline( i = '', make_newline = false ) click to toggle source
#

underline

#
# File lib/colours/toplevel_methods/underline.rb, line 51
def underline(
    i            = '',
    make_newline = false
  )
  Colours.underline(i, make_newline)
end
use_colours?() click to toggle source
#

use_colours?

Delegate towards the class-method here. Unsure whether this method is really needed, but let’s keep it for now. After all we can use “include Colours” to add that method.

#
# File lib/colours/toplevel_methods/use_colours.rb, line 114
def use_colours?
  ::Colours.use_colours?
end
use_new_colour_codes( i = HASH_NEW_COLOURS ) click to toggle source
#

use_new_colour_codes

Use this method to assign new colour codes. We assume that you must pass a hash to this method.

Usage example:

new_hash = {
  :sfancy         => 'green',
  :simportant     => 'teal',
  :default_colour => 'grey',
  :sfile          => 'magenta',
  :sdir           => 'cyan'
}
Colours.assign_new_colour_codes(new_hash)
#
# File lib/colours/colour_table/colour_table.rb, line 167
def use_new_colour_codes(
    i = HASH_NEW_COLOURS
  )
  @colour_table.update(i)
end
Also aliased as: assign_new_colour_codes
write_in_256_colour( i = 'hi there', id = 33 ) click to toggle source
#

write_in_256_colour

Include-able method to the above module-level instance.

#
# File lib/colours/256_colours/support_for_256_colours.rb, line 77
def write_in_256_colour(
    i  = 'hi there',
    id = 33
  )
  write_this_in_256_colours(i, id)
end