class String

Public Instance Methods

dehumanize() click to toggle source
# File lib/string.rb, line 18
def dehumanize
  self.downcase.gsub(/\s/,'-').gsub(/[^a-z0-9-]/,'')
end
to_absolute(base_url) click to toggle source
# File lib/string.rb, line 5
def to_absolute(base_url)
  base = URI.parse base_url
  doc = Nokogiri::HTML self
  [['img','src'],['a','href']].each do |selector,attribute|
    doc.css(selector).each do |tag|
      path = tag[attribute]
      path.slice! 0 if path.start_with? '/'
      tag[attribute] = base.merge(path).to_s
    end
  end
  doc.to_html
end