Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/ext/string.rb,
lib/ext/commify.rb
Instance Method Summary collapse
- #blue ⇒ Object
- #bold ⇒ Object
-
#colorize(color_code) ⇒ Object
rubocop:disable Style/SingleLineMethods.
- #commify ⇒ Object
- #green ⇒ Object
- #invert ⇒ Object
- #red ⇒ Object
- #undent ⇒ Object
Instance Method Details
#blue ⇒ Object
9 |
# File 'lib/ext/string.rb', line 9 def blue() colorize('34'); end |
#bold ⇒ Object
5 |
# File 'lib/ext/string.rb', line 5 def bold() colorize('1'); end |
#colorize(color_code) ⇒ Object
rubocop:disable Style/SingleLineMethods
3 |
# File 'lib/ext/string.rb', line 3 def colorize(color_code) "\e[#{color_code}m#{self}\e[0m"; end |
#commify ⇒ Object
8 9 10 |
# File 'lib/ext/commify.rb', line 8 def commify gsub(/(\d)(?=(\d{3})+(\..*)?$)/, '\1,') end |
#green ⇒ Object
10 |
# File 'lib/ext/string.rb', line 10 def green() colorize('32'); end |
#invert ⇒ Object
6 |
# File 'lib/ext/string.rb', line 6 def invert() colorize('7'); end |
#red ⇒ Object
8 |
# File 'lib/ext/string.rb', line 8 def red() colorize('31'); end |
#undent ⇒ Object
12 |
# File 'lib/ext/string.rb', line 12 def undent() gsub(/^.{#{slice(/^ +/).length}}/, ''); end |