Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/locomotive/core_ext.rb
Overview
String
Instance Method Summary collapse
-
#pathify ⇒ Object
Very similar to the to_url from the Stringex gem except that we allow the dots.
- #pathify! ⇒ Object
-
#permalink(underscore = false) ⇒ Object
:nodoc.
- #permalink!(underscore = false) ⇒ Object (also: #parameterize!)
Instance Method Details
#pathify ⇒ Object
Very similar to the to_url from the Stringex gem except that we allow the dots.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/locomotive/core_ext.rb', line 35 def pathify whitespace_replacement_token = self.index('_').nil? ? '-' : '_' self .convert_smart_punctuation .convert_accented_html_entities .convert_vulgar_fractions .convert_unreadable_control_characters .convert_miscellaneous_html_entities .to_ascii .collapse .replace_whitespace(whitespace_replacement_token) .collapse(whitespace_replacement_token) .downcase end |
#pathify! ⇒ Object
50 51 52 |
# File 'lib/locomotive/core_ext.rb', line 50 def pathify! replace(self.pathify) end |
#permalink(underscore = false) ⇒ Object
:nodoc
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/locomotive/core_ext.rb', line 16 def permalink(underscore = false) # if the slug includes one "_" at least, we consider that the "_" is used instead of "-". _permalink = if !self.index('_').nil? self.to_url(replace_whitespace_with: '_') else self.to_url end underscore ? _permalink.underscore : _permalink end |
#permalink!(underscore = false) ⇒ Object Also known as: parameterize!
27 28 29 |
# File 'lib/locomotive/core_ext.rb', line 27 def permalink!(underscore = false) replace(self.permalink(underscore)) end |