Class | String |
In: |
lib/webby/core_ext/string.rb
|
Parent: | Object |
Removes specified character from the beginning and/or end of the string and then performs String#squeeze(character), condensing runs of the character within the string.
Note: This method has been superceded by ActiveSupport‘s squish method.
Converts HTML entities into the respective non-accented letters. Examples:
"á".convert_accented_entities # => "a" "ç".convert_accented_entities # => "c" "è".convert_accented_entities # => "e" "î".convert_accented_entities # => "i" "ø".convert_accented_entities # => "o" "ü".convert_accented_entities # => "u"
Note: This does not do any conversion of Unicode/Ascii accented-characters. For that functionality please use to_ascii.
Converts various common plaintext characters to a more URI-friendly representation. Examples:
"foo & bar".convert_misc_characters # => "foo and bar" "Chanel #9".convert_misc_characters # => "Chanel number nine" "user@host".convert_misc_characters # => "user at host" "google.com".convert_misc_characters # => "google dot com" "$10".convert_misc_characters # => "10 dollars" "*69".convert_misc_characters # => "star 69" "100%".convert_misc_characters # => "100 percent" "windows/mac/linux".convert_misc_characters # => "windows slash mac slash linux"
Note: Because this method will convert any & symbols to the string "and", you should run any methods which convert HTML entities (convert_html_entities and convert_misc_entities) before running this method.
Converts HTML entities (taken from common Textile/RedCloth formattings) into plain text formats.
Note: This isn‘t an attempt at complete conversion of HTML entities, just those most likely to be generated by Textile.
Performs multiple text manipulations. Essentially a shortcut for typing them all. View source below to see which methods are run.
Replace runs of whitespace in string. Defaults to a single space but any replacement string may be specified as an argument. Examples:
"Foo bar".replace_whitespace # => "Foo bar" "Foo bar".replace_whitespace("-") # => "Foo-bar"
Removes HTML tags from text. This code is simplified from Tobias Luettke‘s regular expression in Typo.