]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
add a first basic colorformat string function
authorMatthias H <apoc@sixserv.org>
Fri, 18 Jul 2014 13:37:26 +0000 (15:37 +0200)
committerMatthias H <apoc@sixserv.org>
Fri, 18 Jul 2014 13:37:26 +0000 (15:37 +0200)
lib/rbot/core/utils/extends.rb

index f36623951ad32ced31d7080091e7da6770ebe369..11ebfc613fd7d6022e5e0bbc61e1ae6918669285 100644 (file)
@@ -370,8 +370,17 @@ class ::String
       "#{pre}#{self}#{post}"
     end
   end
-end
 
+  # Format a string using IRC colors
+  #
+  def colorformat
+    txt = self.dup
+
+    txt.gsub!(/\*([^\*]+)\*/, Bold + '\\1' + NormalText)
+
+    return txt
+  end
+end
 
 # Extensions to the Regexp class, with some common and/or complex regular
 # expressions.