Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/string.rb
Instance Method Summary collapse
Instance Method Details
#dehumanize ⇒ Object
18 19 20 |
# File 'lib/string.rb', line 18 def dehumanize self.downcase.gsub(/\s/,'-').gsub(/[^a-z0-9-]/,'') end |
#to_absolute(base_url) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 |
# 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 |