Class: Rack::UrlStripper::DocumentToStrip
- Inherits:
-
Object
- Object
- Rack::UrlStripper::DocumentToStrip
- Defined in:
- lib/rack_url_stripper/document_to_strip.rb
Instance Method Summary collapse
- #clear_uri_for(element, attribute) ⇒ Object
-
#initialize(body) ⇒ DocumentToStrip
constructor
A new instance of DocumentToStrip.
- #remove_tag(tag_name) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(body) ⇒ DocumentToStrip
Returns a new instance of DocumentToStrip.
4 5 6 |
# File 'lib/rack_url_stripper/document_to_strip.rb', line 4 def initialize(body) @doc = Nokogiri::HTML.parse(body) end |
Instance Method Details
#clear_uri_for(element, attribute) ⇒ Object
8 9 10 11 12 |
# File 'lib/rack_url_stripper/document_to_strip.rb', line 8 def clear_uri_for(element, attribute) @doc.xpath("//#{element}/@#{attribute}").each do |i| i.value = '#' end end |
#remove_tag(tag_name) ⇒ Object
14 15 16 |
# File 'lib/rack_url_stripper/document_to_strip.rb', line 14 def remove_tag(tag_name) @doc.xpath("//#{tag_name}").remove() end |
#to_s ⇒ Object
18 19 20 |
# File 'lib/rack_url_stripper/document_to_strip.rb', line 18 def to_s @doc.to_s end |