class String
FIXME: Replace with helpers and/or methods provided by Rails
Constants
- ACCENTS
- TAG
- TYPO_ATTRIBUTE
- TYPO_ATTRIBUTES
- TYPO_ATTRIBUTE_VALUE
- TYPO_TAG_KEY
Strips any html markup from a string
Public Instance Methods
strip_html()
click to toggle source
# File lib/transforms.rb, line 44 def strip_html gsub(TAG, "").gsub(/\s+/, " ").strip end
to_permalink()
click to toggle source
# File lib/transforms.rb, line 14 def to_permalink string = self ACCENTS.each do |key, value| string = string.tr(key.join, value) end string = string.tr("'", "-") string.gsub(/<[^>]*>/, "").to_url end
to_title(item, settings, params)
click to toggle source
# File lib/transforms.rb, line 33 def to_title(item, settings, params) TitleBuilder.new(self).build(item, settings, params) end
to_url()
click to toggle source
Returns a-string-with-dashes when passed 'a string with dashes'. All special chars are stripped in the process
# File lib/transforms.rb, line 25 def to_url return if nil? s = downcase.tr("\"'", "") s = s.gsub(/\P{Word}/, " ") s.strip.tr_s(" ", "-").tr(" ", "-").sub(/^$/, "-") end