Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/trellohub/core_ext/string.rb
Instance Method Summary collapse
- #constantize ⇒ Object
- #ljust_with_multibyte(length, padstr = ' ') ⇒ Object (also: #ljust)
- #no_coloring ⇒ Object
- #width ⇒ Object
Instance Method Details
#constantize ⇒ Object
14 15 16 |
# File 'lib/trellohub/core_ext/string.rb', line 14 def constantize Object.const_get(self) end |
#ljust_with_multibyte(length, padstr = ' ') ⇒ Object Also known as: ljust
18 19 20 |
# File 'lib/trellohub/core_ext/string.rb', line 18 def ljust_with_multibyte(length, padstr = ' ') length > self.width ? "#{self}#{padstr * (length - self.width)}" : self end |
#no_coloring ⇒ Object
10 11 12 |
# File 'lib/trellohub/core_ext/string.rb', line 10 def no_coloring self.gsub(/\e\[\d?\d?;?\d\d?m/, '').gsub(/\e\[0m/, '') end |
#width ⇒ Object
4 5 6 7 8 |
# File 'lib/trellohub/core_ext/string.rb', line 4 def width self.no_coloring.each_char.map { |one_letter| one_letter.ascii_only? ? 1 : 2 }.inject(:+) || 0 end |