Module LuckySneaks::StringExtensions
In: lib/lucky_sneaks/string_extensions.rb
lib/lucky_sneaks/unidecoder.rb

These methods are all added on String class.

Methods

Classes and Modules

Module LuckySneaks::StringExtensions::ClassMethods

Public Instance methods

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 German Umlauts to their transliteration according to German conventions.

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.

Returns string with its UTF-8 characters transliterated to ASCII ones. Example:

  "⠋⠗⠁⠝⠉⠑".to_ascii #=> "braille"

Returns the string converted (via Textile/RedCloth) to HTML format or self [with a friendly warning] if Redcloth is not available.

Using :lite argument will cause RedCloth to not wrap the HTML in a container P element, which is useful behavior for generating header element text, etc. This is roughly equivalent to ActionView‘s textilize_without_paragraph except that it makes RedCloth do all the work instead of just gsubbing the return from RedCloth.

Create a URI-friendly representation of the string. This is used internally by acts_as_url but can be called manually in order to generate an URI-friendly version of any string.

[Validate]