Class: Html2rss::ItemExtractors::Href
- Inherits:
-
Object
- Object
- Html2rss::ItemExtractors::Href
- Defined in:
- lib/html2rss/item_extractors/href.rb
Overview
Returns the value of the href
attribute. It always returns absolute URLs. If the extracted href
value is a relative URL, it prepends the channel's URL.
Imagine this a
HTML element with a href
attribute:
<a href="/posts/latest-findings">...</a>
YAML usage example:
channel:
url: http://blog-without-a-feed.example.com
...
selectors:
link:
selector: a
extractor: href
Would return:
'http://blog-without-a-feed.example.com/posts/latest-findings'
Instance Method Summary collapse
- #get ⇒ URI::HTTPS, URI::HTTP
-
#initialize(xml, options) ⇒ Href
constructor
A new instance of Href.
Constructor Details
#initialize(xml, options) ⇒ Href
Returns a new instance of Href
24 25 26 27 28 |
# File 'lib/html2rss/item_extractors/href.rb', line 24 def initialize(xml, ) @options = element = ItemExtractors.element(xml, ) @href = element.attr('href').to_s end |
Instance Method Details
#get ⇒ URI::HTTPS, URI::HTTP
31 32 33 |
# File 'lib/html2rss/item_extractors/href.rb', line 31 def get Html2rss::Utils.build_absolute_url_from_relative(@href, @options['channel']['url']) end |