Sha256: 5831f00476c781514e98beaf117b2b774e39aaea1a3e82a2add6a77d30d0f4ae
Contents?: true
Size: 770 Bytes
Versions: 7
Compression:
Stored size: 770 Bytes
Contents
class String def underscore self.gsub(/::/, '/'). gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). gsub(/([a-z\d])([A-Z])/,'\1_\2'). tr('-', '_'). downcase end def replace_tags(tags) str = self tags.each { |name, value| str = str.gsub(%r(\$\{#{name.to_s}\})m, value) } str end def replace_tags!(tags) tags.each { |name, value| self.gsub!(%r(\$\{#{name.to_s}\})m, value) } self end # colorization def colorize(color_code) "\e[#{color_code}m#{self}\e[0m" end def red colorize(31) end def green colorize(32) end def yellow colorize(33) end def blue colorize(34) end def pink colorize(35) end def light_blue colorize(36) end end
Version data entries
7 entries across 7 versions & 2 rubygems