Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/dvla/herodotus/string.rb
Instance Method Summary collapse
- #bg_black ⇒ Object
- #bg_blue ⇒ Object
- #bg_bright_blue ⇒ Object
- #bg_bright_cyan ⇒ Object
- #bg_bright_green ⇒ Object
- #bg_bright_magenta ⇒ Object
- #bg_bright_red ⇒ Object
- #bg_brown ⇒ Object
- #bg_cyan ⇒ Object
- #bg_gray ⇒ Object (also: #bg_grey)
- #bg_green ⇒ Object
- #bg_magenta ⇒ Object
- #bg_red ⇒ Object
- #bg_white ⇒ Object
- #bg_yellow ⇒ Object
- #black ⇒ Object
- #blue ⇒ Object
- #bold ⇒ Object
- #bright_blue ⇒ Object
- #bright_cyan ⇒ Object
- #bright_green ⇒ Object
- #bright_magenta ⇒ Object
- #bright_red ⇒ Object
- #brown ⇒ Object
- #colourise(code, reset_code = 39) ⇒ Object (also: #colorize)
-
#config ⇒ Object
Semantic logging methods - apply colours based on message type.
- #cyan ⇒ Object
- #data ⇒ Object
- #dim ⇒ Object
- #gray ⇒ Object (also: #grey)
- #green ⇒ Object
- #italic ⇒ Object
- #magenta ⇒ Object
- #red ⇒ Object
- #reverse_colour ⇒ Object (also: #reverse_color)
- #step ⇒ Object
- #strip_colour ⇒ Object (also: #strip_color)
- #success ⇒ Object
- #underline ⇒ Object
- #warning ⇒ Object
- #white ⇒ Object
- #yellow ⇒ Object
Instance Method Details
#bg_black ⇒ Object
44 |
# File 'lib/dvla/herodotus/string.rb', line 44 def bg_black = colourise(40, 49) |
#bg_blue ⇒ Object
54 |
# File 'lib/dvla/herodotus/string.rb', line 54 def bg_blue = colourise(44, 49) |
#bg_bright_blue ⇒ Object
68 |
# File 'lib/dvla/herodotus/string.rb', line 68 def bg_bright_blue = colourise(104, 49) |
#bg_bright_cyan ⇒ Object
72 |
# File 'lib/dvla/herodotus/string.rb', line 72 def bg_bright_cyan = colourise(106, 49) |
#bg_bright_green ⇒ Object
66 |
# File 'lib/dvla/herodotus/string.rb', line 66 def bg_bright_green = colourise(102, 49) |
#bg_bright_magenta ⇒ Object
70 |
# File 'lib/dvla/herodotus/string.rb', line 70 def bg_bright_magenta = colourise(105, 49) |
#bg_bright_red ⇒ Object
64 |
# File 'lib/dvla/herodotus/string.rb', line 64 def bg_bright_red = colourise(101, 49) |
#bg_brown ⇒ Object
50 |
# File 'lib/dvla/herodotus/string.rb', line 50 def bg_brown = colourise(43, 49) |
#bg_cyan ⇒ Object
58 |
# File 'lib/dvla/herodotus/string.rb', line 58 def bg_cyan = colourise(46, 49) |
#bg_gray ⇒ Object Also known as: bg_grey
60 |
# File 'lib/dvla/herodotus/string.rb', line 60 def bg_gray = colourise(47, 49) |
#bg_green ⇒ Object
48 |
# File 'lib/dvla/herodotus/string.rb', line 48 def bg_green = colourise(42, 49) |
#bg_magenta ⇒ Object
56 |
# File 'lib/dvla/herodotus/string.rb', line 56 def bg_magenta = colourise(45, 49) |
#bg_red ⇒ Object
46 |
# File 'lib/dvla/herodotus/string.rb', line 46 def bg_red = colourise(41, 49) |
#bg_white ⇒ Object
62 |
# File 'lib/dvla/herodotus/string.rb', line 62 def bg_white = colourise(107, 49) |
#bg_yellow ⇒ Object
52 |
# File 'lib/dvla/herodotus/string.rb', line 52 def bg_yellow = colourise(103, 49) |
#black ⇒ Object
16 |
# File 'lib/dvla/herodotus/string.rb', line 16 def black = colourise(30) |
#blue ⇒ Object
26 |
# File 'lib/dvla/herodotus/string.rb', line 26 def blue = colourise(34) |
#bold ⇒ Object
74 |
# File 'lib/dvla/herodotus/string.rb', line 74 def bold = colourise(1, 22) |
#bright_blue ⇒ Object
38 |
# File 'lib/dvla/herodotus/string.rb', line 38 def bright_blue = colourise(94) |
#bright_cyan ⇒ Object
42 |
# File 'lib/dvla/herodotus/string.rb', line 42 def bright_cyan = colourise(96) |
#bright_green ⇒ Object
36 |
# File 'lib/dvla/herodotus/string.rb', line 36 def bright_green = colourise(92) |
#bright_magenta ⇒ Object
40 |
# File 'lib/dvla/herodotus/string.rb', line 40 def bright_magenta = colourise(95) |
#bright_red ⇒ Object
34 |
# File 'lib/dvla/herodotus/string.rb', line 34 def bright_red = colourise(91) |
#brown ⇒ Object
22 |
# File 'lib/dvla/herodotus/string.rb', line 22 def brown = colourise(33) |
#colourise(code, reset_code = 39) ⇒ Object Also known as: colorize
4 5 6 7 8 9 10 11 12 |
# File 'lib/dvla/herodotus/string.rb', line 4 def colourise(code, reset_code = 39) # Making sure we align the correct reset codes if self.include?("\e[#{reset_code}m") result = self.gsub("\e[#{reset_code}m", "\e[#{reset_code}m\e[#{code}m") "\e[#{code}m#{result}\e[#{reset_code}m" else "\e[#{code}m#{self}\e[#{reset_code}m" end end |
#config ⇒ Object
Semantic logging methods - apply colours based on message type
95 96 97 |
# File 'lib/dvla/herodotus/string.rb', line 95 def config send(DVLA::Herodotus::SemanticColours.config) end |
#cyan ⇒ Object
30 |
# File 'lib/dvla/herodotus/string.rb', line 30 def cyan = colourise(36) |
#data ⇒ Object
111 112 113 |
# File 'lib/dvla/herodotus/string.rb', line 111 def data send(DVLA::Herodotus::SemanticColours.data) end |
#dim ⇒ Object
76 |
# File 'lib/dvla/herodotus/string.rb', line 76 def dim = colourise(2, 22) |
#gray ⇒ Object Also known as: grey
32 |
# File 'lib/dvla/herodotus/string.rb', line 32 def gray = colourise(37) |
#green ⇒ Object
20 |
# File 'lib/dvla/herodotus/string.rb', line 20 def green = colourise(32) |
#italic ⇒ Object
78 |
# File 'lib/dvla/herodotus/string.rb', line 78 def italic = colourise(3, 23) |
#magenta ⇒ Object
28 |
# File 'lib/dvla/herodotus/string.rb', line 28 def magenta = colourise(35) |
#red ⇒ Object
18 |
# File 'lib/dvla/herodotus/string.rb', line 18 def red = colourise(31) |
#reverse_colour ⇒ Object Also known as: reverse_color
82 |
# File 'lib/dvla/herodotus/string.rb', line 82 def reverse_colour = colourise(7, 27) |
#step ⇒ Object
99 100 101 |
# File 'lib/dvla/herodotus/string.rb', line 99 def step send(DVLA::Herodotus::SemanticColours.step) end |
#strip_colour ⇒ Object Also known as: strip_color
84 85 86 |
# File 'lib/dvla/herodotus/string.rb', line 84 def strip_colour gsub(/\e\[[0-9;]*m/, '') end |
#success ⇒ Object
103 104 105 |
# File 'lib/dvla/herodotus/string.rb', line 103 def success send(DVLA::Herodotus::SemanticColours.success) end |
#underline ⇒ Object
80 |
# File 'lib/dvla/herodotus/string.rb', line 80 def underline = colourise(4, 24) |
#warning ⇒ Object
107 108 109 |
# File 'lib/dvla/herodotus/string.rb', line 107 def warning send(DVLA::Herodotus::SemanticColours.warning) end |
#white ⇒ Object
14 |
# File 'lib/dvla/herodotus/string.rb', line 14 def white = colourise(97) |
#yellow ⇒ Object
24 |
# File 'lib/dvla/herodotus/string.rb', line 24 def yellow = colourise(93) |