Module: Colours::Essentials
- Included in:
- TestClass
- Defined in:
- lib/colours/essentials/essentials.rb
Overview
Colours::Essentials
Constant Summary collapse
- NAMESPACE =
#
Colours::Essentials::NAMESPACE
#
const_get(inspect)
Class Method Summary collapse
-
.black(i = '') ⇒ Object
# === Colours.black ========================================================================= #.
-
.blue(i = '') ⇒ Object
# === Colours.blue ========================================================================= #.
-
.brown(i = '') ⇒ Object
# === Colours.brown.
-
.cyan(i = '') ⇒ Object
# === Colours.cyan ========================================================================= #.
-
.dark_gray(i = '') ⇒ Object
# === Colours::Essentials.dark_gray ========================================================================= #.
-
.define_colour_methods_that_can_be_included ⇒ Object
# === Colours.define_colour_methods_that_can_be_included.
-
.green(i = '') ⇒ Object
# === Colours.green ========================================================================= #.
-
.grey(i = '') ⇒ Object
# === Colours.grey ========================================================================= #.
-
.light_blue(i = '') ⇒ Object
# === Colours::Essentials.light_blue ========================================================================= #.
-
.light_cyan(i = '') ⇒ Object
# === Colours.light_cyan ========================================================================= #.
-
.light_gray(i = '') ⇒ Object
# === Colours::Essentials.light_gray ========================================================================= #.
-
.light_green(i = '') ⇒ Object
# === Colours::Essentials.light_green ========================================================================= #.
-
.light_magenta(i = '') ⇒ Object
# === Colours.light_magenta ========================================================================= #.
-
.light_red(i = '') ⇒ Object
# === Colours.light_red ========================================================================= #.
-
.magenta(i = '') ⇒ Object
# === Colours::Essentials.magenta ========================================================================= #.
-
.red(i = '') ⇒ Object
# === Colours::Essentials.red ========================================================================= #.
-
.white(i = '') ⇒ Object
# === Colours::Essentials.white ========================================================================= #.
-
.yellow(i = '') ⇒ Object
# === Colours::Essentials.yellow ========================================================================= #.
Instance Method Summary collapse
-
#blue(i = '') ⇒ Object
# === blue ========================================================================= #.
-
#bold_green(i = '') ⇒ Object
(also: #greenb)
# === bold_green ========================================================================= #.
-
#bold_red(i = '') ⇒ Object
(also: #lightred, #redb)
# === bold_red ========================================================================= #.
-
#bold_white(i = '') ⇒ Object
(also: #whiteb)
# === bold_white ========================================================================= #.
-
#bold_yellow(i = '') ⇒ Object
(also: #yelb)
# === bold_yellow ========================================================================= #.
-
#cyan(i = '') ⇒ Object
# === cyan ========================================================================= #.
-
#grey(i = '') ⇒ Object
(also: #gray)
# === grey ========================================================================= #.
-
#light_blue(i = '') ⇒ Object
(also: #lightblue, #bold_blue)
# === light_blue ========================================================================= #.
-
#light_green(i = '') ⇒ Object
# === light_green ========================================================================= #.
-
#light_magenta(i = '') ⇒ Object
# === light_magenta ========================================================================= #.
-
#light_red(i = '') ⇒ Object
# === light_red ========================================================================= #.
-
#magenta(i = '') ⇒ Object
(also: #purple)
# === magenta ========================================================================= #.
-
#red(i = '') ⇒ Object
# === red ========================================================================= #.
-
#yellow(i = '') ⇒ Object
(also: #brown, #yel, #bold_brown)
# === yellow ========================================================================= #.
Class Method Details
.black(i = '') ⇒ Object
#
Colours.black
#
172 173 174 |
# File 'lib/colours/essentials/essentials.rb', line 172 def self.black(i = '') "#{COLOUR_BLACK}#{i}#{REVERT}" end |
.blue(i = '') ⇒ Object
#
Colours.blue
#
96 97 98 |
# File 'lib/colours/essentials/essentials.rb', line 96 def self.blue(i = '') "#{COLOUR_BLUE}#{i}#{REVERT}" end |
.brown(i = '') ⇒ Object
#
Colours.brown
Note that Colours.bold_yellow is an alias to this method.
#
157 158 159 |
# File 'lib/colours/essentials/essentials.rb', line 157 def self.brown(i = '') "#{COLOUR_BROWN}#{i}#{REVERT}" end |
.cyan(i = '') ⇒ Object
#
Colours.cyan
#
197 198 199 |
# File 'lib/colours/essentials/essentials.rb', line 197 def self.cyan(i = '') "#{COLOUR_CYAN}#{i}#{REVERT}" end |
.dark_gray(i = '') ⇒ Object
#
Colours::Essentials.dark_gray
#
188 189 190 |
# File 'lib/colours/essentials/essentials.rb', line 188 def self.dark_gray(i = '') "#{COLOUR_DARK_GRAY}#{i}#{REVERT}" end |
.define_colour_methods_that_can_be_included ⇒ Object
#
Colours.define_colour_methods_that_can_be_included
Dynamic definitions of some methods, such as teal() or red() or white() or bold_white() or lightblue(). These will be defined at include-time, meaning that they will only be available if you do “include Colours”.
Should come up very early in the definition, as other methods may depend on it.
To test this, try:
Colours.bold_yellow('hey joe')
#
275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 |
# File 'lib/colours/essentials/essentials.rb', line 275 def self.define_colour_methods_that_can_be_included all_colours = ::Colours.really_all_colours # ======================================================================= # # The above refers to an Array that looks 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] # # ======================================================================= # all_colours.each {|entry| unless defined? entry.to_sym # Must prevent re-definitions here. define_method(entry.to_sym) {|i = ''| # Allow input. i = i.to_s _ = ''.dup _ << "#{map_colour_to_constant(__method__)}" _ << "#{i}#{rev}" unless i.empty? return _ } end } end |
.green(i = '') ⇒ Object
#
Colours.green
#
148 149 150 |
# File 'lib/colours/essentials/essentials.rb', line 148 def self.green(i = '') "#{COLOUR_GREEN}#{i}#{REVERT}" end |
.grey(i = '') ⇒ Object
#
Colours.grey
#
211 212 213 |
# File 'lib/colours/essentials/essentials.rb', line 211 def self.grey(i = '') "#{COLOUR_GRAY}#{i}#{REVERT}" end |
.light_blue(i = '') ⇒ Object
#
Colours::Essentials.light_blue
#
37 38 39 |
# File 'lib/colours/essentials/essentials.rb', line 37 def self.light_blue(i = '') "#{COLOUR_LIGHT_BLUE}#{i}#{REVERT}" end |
.light_cyan(i = '') ⇒ Object
#
Colours.light_cyan
#
165 166 167 |
# File 'lib/colours/essentials/essentials.rb', line 165 def self.light_cyan(i = '') "#{COLOUR_LIGHT_CYAN}#{i}#{REVERT}" end |
.light_gray(i = '') ⇒ Object
#
Colours::Essentials.light_gray
#
179 180 181 |
# File 'lib/colours/essentials/essentials.rb', line 179 def self.light_gray(i = '') "#{COLOUR_LIGHT_GRAY}#{i}#{REVERT}" end |
.light_green(i = '') ⇒ Object
#
Colours::Essentials.light_green
#
67 68 69 |
# File 'lib/colours/essentials/essentials.rb', line 67 def self.light_green(i = '') "#{COLOUR_LIGHT_GREEN}#{i}#{REVERT}" end |
.light_magenta(i = '') ⇒ Object
#
Colours.light_magenta
#
117 118 119 |
# File 'lib/colours/essentials/essentials.rb', line 117 def self.light_magenta(i = '') "#{COLOUR_LIGHT_MAGENTA}#{i}#{REVERT}" end |
.light_red(i = '') ⇒ Object
#
Colours.light_red
#
239 240 241 |
# File 'lib/colours/essentials/essentials.rb', line 239 def self.light_red(i = '') "#{COLOUR_LIGHT_RED}#{i}#{REVERT}" end |
.magenta(i = '') ⇒ Object
#
Colours::Essentials.magenta
#
53 54 55 |
# File 'lib/colours/essentials/essentials.rb', line 53 def self.magenta(i = '') "#{COLOUR_MAGENTA}#{i}#{REVERT}" end |
.red(i = '') ⇒ Object
#
Colours::Essentials.red
#
82 83 84 |
# File 'lib/colours/essentials/essentials.rb', line 82 def self.red(i = '') "#{COLOUR_RED}#{i}#{REVERT}" end |
.white(i = '') ⇒ Object
#
Colours::Essentials.white
#
225 226 227 |
# File 'lib/colours/essentials/essentials.rb', line 225 def self.white(i = '') "#{COLOUR_WHITE}#{i}#{REVERT}" end |
.yellow(i = '') ⇒ Object
#
Colours::Essentials.yellow
#
29 30 31 |
# File 'lib/colours/essentials/essentials.rb', line 29 def self.yellow(i = '') "#{COLOUR_YELLOW}#{i}#{REVERT}" end |
Instance Method Details
#blue(i = '') ⇒ Object
#
blue
#
103 104 105 |
# File 'lib/colours/essentials/essentials.rb', line 103 def blue(i = '') NAMESPACE.blue(i) end |
#bold_green(i = '') ⇒ Object Also known as: greenb
#
bold_green
#
75 76 77 |
# File 'lib/colours/essentials/essentials.rb', line 75 def bold_green(i = '') ::NAMESPACE.bold_green(i) end |
#bold_red(i = '') ⇒ Object Also known as: lightred, redb
#
bold_red
#
247 248 249 |
# File 'lib/colours/essentials/essentials.rb', line 247 def bold_red(i = '') NAMESPACE.bold_red(i) end |
#bold_white(i = '') ⇒ Object Also known as: whiteb
#
bold_white
#
232 233 234 |
# File 'lib/colours/essentials/essentials.rb', line 232 def bold_white(i = '') NAMESPACE.bold_white(i) end |
#bold_yellow(i = '') ⇒ Object Also known as: yelb
#
bold_yellow
#
255 256 257 |
# File 'lib/colours/essentials/essentials.rb', line 255 def bold_yellow(i = '') NAMESPACE.bold_yellow(i) end |
#cyan(i = '') ⇒ Object
#
cyan
#
204 205 206 |
# File 'lib/colours/essentials/essentials.rb', line 204 def cyan(i = '') NAMESPACE.cyan(i) end |
#grey(i = '') ⇒ Object Also known as: gray
#
grey
#
218 219 220 |
# File 'lib/colours/essentials/essentials.rb', line 218 def grey(i = '') NAMESPACE.grey(i) end |
#light_blue(i = '') ⇒ Object Also known as: lightblue, bold_blue
#
light_blue
#
45 46 47 |
# File 'lib/colours/essentials/essentials.rb', line 45 def light_blue(i = '') NAMESPACE.light_blue(i) end |
#light_green(i = '') ⇒ Object
#
light_green
#
110 111 112 |
# File 'lib/colours/essentials/essentials.rb', line 110 def light_green(i = '') NAMESPACE.light_green(i) end |
#light_magenta(i = '') ⇒ Object
#
light_magenta
#
125 126 127 |
# File 'lib/colours/essentials/essentials.rb', line 125 def light_magenta(i = '') NAMESPACE.light_magenta(i) end |
#light_red(i = '') ⇒ Object
#
light_red
#
141 142 143 |
# File 'lib/colours/essentials/essentials.rb', line 141 def light_red(i = '') NAMESPACE.light_red(i) end |
#magenta(i = '') ⇒ Object Also known as: purple
#
magenta
#
60 61 62 |
# File 'lib/colours/essentials/essentials.rb', line 60 def magenta(i = '') NAMESPACE.magenta(i) end |