Sha256: a4c4fc3fad9c132d29e90a2c1b3d9e928cb7a7a3f9b78f7353ca58813a809e95
Contents?: true
Size: 706 Bytes
Versions: 14
Compression:
Stored size: 706 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_quoted_string '"' + self.gsub('"', '\\"').gsub(/\r/, "\\r").gsub(/\n/, "\\n") + '"' 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
14 entries across 14 versions & 1 rubygems