Module: Kolorit::Linux
- Included in:
- Windows
- Defined in:
- lib/kolorit/linux.rb
Overview
Color codes for Linux systems. Allow use of color methods in many different ways.
Include methods outside of main module to use them directly on string (or integer, array, hash). This is done when you call ‘require ’kolorit’‘. You can also just include it in class where you want to use it:
Instance Method Summary collapse
- #blink(str = nil) ⇒ Object
- #blue(str = nil) ⇒ Object
- #bold(str = nil) ⇒ Object
- #colorize(color, string = nil, &blk) ⇒ Object
- #cyan(str = nil) ⇒ Object
- #gray(str = nil) ⇒ Object
- #green(str = nil) ⇒ Object
- #italic(str = nil) ⇒ Object
- #kolorize(string, color = nil, &blk) ⇒ Object
- #pink(str = nil) ⇒ Object
- #red(str = nil) ⇒ Object
- #reverse_color(str = nil) ⇒ Object (also: #inverse)
- #underline(str = nil) ⇒ Object
- #yellow(str = nil) ⇒ Object
Instance Method Details
#blink(str = nil) ⇒ Object
97 98 99 |
# File 'lib/kolorit/linux.rb', line 97 def blink(str = nil) kolor(5, str) end |
#blue(str = nil) ⇒ Object
69 70 71 |
# File 'lib/kolorit/linux.rb', line 69 def blue(str = nil) kolor(34, str) end |
#bold(str = nil) ⇒ Object
85 86 87 |
# File 'lib/kolorit/linux.rb', line 85 def bold(str = nil) kolor(1, str) end |
#colorize(color, string = nil, &blk) ⇒ Object
107 108 109 110 111 |
# File 'lib/kolorit/linux.rb', line 107 def colorize(color, string = nil, &blk) string = yield(blk) if block_given? color = KOLORS[color.to_sym] unless color.is_a?(Integer) kolor color, string end |
#cyan(str = nil) ⇒ Object
77 78 79 |
# File 'lib/kolorit/linux.rb', line 77 def cyan(str = nil) kolor(36, str) end |
#gray(str = nil) ⇒ Object
81 82 83 |
# File 'lib/kolorit/linux.rb', line 81 def gray(str = nil) kolor(37, str) end |
#green(str = nil) ⇒ Object
61 62 63 |
# File 'lib/kolorit/linux.rb', line 61 def green(str = nil) kolor(32, str) end |
#italic(str = nil) ⇒ Object
89 90 91 |
# File 'lib/kolorit/linux.rb', line 89 def italic(str = nil) kolor(3, str) end |
#kolorize(string, color = nil, &blk) ⇒ Object
113 114 115 116 117 |
# File 'lib/kolorit/linux.rb', line 113 def kolorize(string, color = nil, &blk) color = yield(blk) if block_given? color = KOLORS[color.to_sym] unless color.is_a?(Integer) kolor color, string end |
#pink(str = nil) ⇒ Object
73 74 75 |
# File 'lib/kolorit/linux.rb', line 73 def pink(str = nil) kolor(35, str) end |
#red(str = nil) ⇒ Object
57 58 59 |
# File 'lib/kolorit/linux.rb', line 57 def red(str = nil) kolor(31, str) end |
#reverse_color(str = nil) ⇒ Object Also known as: inverse
101 102 103 |
# File 'lib/kolorit/linux.rb', line 101 def reverse_color(str = nil) kolor(7, str) end |
#underline(str = nil) ⇒ Object
93 94 95 |
# File 'lib/kolorit/linux.rb', line 93 def underline(str = nil) kolor(4, str) end |
#yellow(str = nil) ⇒ Object
65 66 67 |
# File 'lib/kolorit/linux.rb', line 65 def yellow(str = nil) kolor(33, str) end |