Method: Stringex::StringExtensions::PublicInstanceMethods#to_url
- Defined in:
- lib/stringex/string_extensions.rb
#to_url(options = {}) ⇒ Object
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.
191 192 193 194 195 196 197 198 199 200 201 |
# File 'lib/stringex/string_extensions.rb', line 191 def to_url( = {}) return self if [:exclude] && [:exclude].include?(self) = .merge() whitespace_replacement_token = [:replace_whitespace_with] dummy = remove_formatting(). replace_whitespace(whitespace_replacement_token). collapse(whitespace_replacement_token). limit([:limit], [:truncate_words], whitespace_replacement_token) dummy.downcase! unless [:force_downcase] == false dummy end |