Class: String
Instance Method Summary collapse
-
#capitalize_each ⇒ Object
Capitalize each word in a string.
-
#capitalize_each! ⇒ Object
Capitalize each word in a string.
-
#crc32 ⇒ Object
Returns a CRC32 value for the string.
-
#decode_base64 ⇒ Object
Return a Base64 decoded version of the string.
-
#decode_base64! ⇒ Object
Return a Base64 decoded version of the string.
-
#each_word ⇒ Object
Return an array of each word in a string.
-
#encode_base64 ⇒ Object
Return a Base64 encoded version of the string.
-
#encode_base64! ⇒ Object
Return a Base64 encoded version of the string.
-
#escapeHTML ⇒ Object
Escape a string using HTML-escapement.
-
#escapeHTML! ⇒ Object
Escape a string using HTML-escapement inline.
-
#first_words(count) ⇒ Object
Return the first n words in a string.
-
#md5 ⇒ Object
Return an MD5 digest of the string.
-
#unescapeHTML ⇒ Object
Unescape an HTML-escaped string.
-
#unescapeHTML! ⇒ Object
Unescape an HTML-escaped string inline.
Instance Method Details
#capitalize_each ⇒ Object
Capitalize each word in a string
4 5 6 |
# File 'lib/string.rb', line 4 def capitalize_each self.split(" ").each{|word| word.capitalize!}.join(" ") end |
#capitalize_each! ⇒ Object
Capitalize each word in a string
9 10 11 |
# File 'lib/string.rb', line 9 def capitalize_each! replace capitalize_each end |
#crc32 ⇒ Object
Returns a CRC32 value for the string
24 25 26 |
# File 'lib/string.rb', line 24 def crc32 Zlib.crc32(self) end |
#decode_base64 ⇒ Object
Return a Base64 decoded version of the string
39 40 41 |
# File 'lib/string.rb', line 39 def decode_base64 Base64.decode64(self) end |
#decode_base64! ⇒ Object
Return a Base64 decoded version of the string
49 50 51 |
# File 'lib/string.rb', line 49 def decode_base64! replace Base64.decode64(self) end |
#each_word ⇒ Object
Return an array of each word in a string
14 15 16 |
# File 'lib/string.rb', line 14 def each_word split(/\s+/) end |
#encode_base64 ⇒ Object
Return a Base64 encoded version of the string
34 35 36 |
# File 'lib/string.rb', line 34 def encode_base64 Base64.encode64(self) end |
#encode_base64! ⇒ Object
Return a Base64 encoded version of the string
44 45 46 |
# File 'lib/string.rb', line 44 def encode_base64! replace Base64.encode64(self) end |
#escapeHTML ⇒ Object
Escape a string using HTML-escapement
54 55 56 |
# File 'lib/string.rb', line 54 def escapeHTML CGI::escapeHTML(self) end |
#escapeHTML! ⇒ Object
Escape a string using HTML-escapement inline
59 60 61 |
# File 'lib/string.rb', line 59 def escapeHTML! replace CGI::escapeHTML(self) end |
#first_words(count) ⇒ Object
Return the first n words in a string
19 20 21 |
# File 'lib/string.rb', line 19 def first_words(count) each_word.first(count).join(" ") end |
#md5 ⇒ Object
Return an MD5 digest of the string
29 30 31 |
# File 'lib/string.rb', line 29 def md5 Digest::MD5.hexdigest(self) end |
#unescapeHTML ⇒ Object
Unescape an HTML-escaped string
64 65 66 |
# File 'lib/string.rb', line 64 def unescapeHTML CGI::unescapeHTML(self) end |
#unescapeHTML! ⇒ Object
Unescape an HTML-escaped string inline
69 70 71 |
# File 'lib/string.rb', line 69 def unescapeHTML! replace CGI::unescapeHTML(self) end |