Class: String
- Defined in:
- lib/core_ext/string/color.rb,
lib/core_ext/string/indent.rb,
lib/core_ext/string/unindent.rb
Instance Method Summary collapse
-
#colorize(color_code) ⇒ Object
colorization.
- #green ⇒ Object
- #indent(level) ⇒ Object
- #pink ⇒ Object
- #red ⇒ Object
- #unindent ⇒ Object
- #yellow ⇒ Object
Instance Method Details
#colorize(color_code) ⇒ Object
colorization
3 4 5 |
# File 'lib/core_ext/string/color.rb', line 3 def colorize(color_code) "\e[#{color_code}m#{self}\e[0m" end |
#green ⇒ Object
11 12 13 |
# File 'lib/core_ext/string/color.rb', line 11 def green colorize(32) end |
#indent(level) ⇒ Object
2 3 4 |
# File 'lib/core_ext/string/indent.rb', line 2 def indent(level) split("\n").map { |line| ' ' * (level * 2) + line }.join("\n") end |
#pink ⇒ Object
19 20 21 |
# File 'lib/core_ext/string/color.rb', line 19 def pink colorize(35) end |
#red ⇒ Object
7 8 9 |
# File 'lib/core_ext/string/color.rb', line 7 def red colorize(31) end |
#unindent ⇒ Object
2 3 4 |
# File 'lib/core_ext/string/unindent.rb', line 2 def unindent gsub /^#{self[/\A\s*/]}/, '' end |
#yellow ⇒ Object
15 16 17 |
# File 'lib/core_ext/string/color.rb', line 15 def yellow colorize(33) end |