Sha256: 0349105314c06b1ab582cbd679c3e4292505dc98acf6d5d5d455ee9d05e878a1
Contents?: true
Size: 606 Bytes
Versions: 12
Compression:
Stored size: 606 Bytes
Contents
# This file is part of the "Utopia Framework" project, and is licensed under the GNU AGPLv3. # Copyright 2010 Samuel Williams. All rights reserved. # See <utopia.rb> for licensing details. class String HTML_ESCAPE = {"&" => "&", "<" => "<", ">" => ">", "\"" => """} HTML_ESCAPE_PATTERN = Regexp.new("[" + Regexp.quote(HTML_ESCAPE.keys.join) + "]") def to_html gsub(HTML_ESCAPE_PATTERN){|c| HTML_ESCAPE[c]} end def to_title (" " + self).gsub(/[ \-_](.)/){" " + $1.upcase}.strip end def to_snake self.gsub("::", "").gsub(/([A-Z]+)/){"_" + $1.downcase}.sub(/^_+/, "") end end
Version data entries
12 entries across 12 versions & 1 rubygems