Class: Html2rss::AttributePostProcessors::ParseUri
- Inherits:
-
Object
- Object
- Html2rss::AttributePostProcessors::ParseUri
- Defined in:
- lib/html2rss/attribute_post_processors/parse_uri.rb
Overview
Returns the URI as String. If the URL is relative, it builds an absolute one with the channel’s URL as base.
Imagine this HTML structure:
<span>http://why-not-use-a-link.uh </span>
YAML usage example:
selectors:
link:
selector: span
extractor: text
post_process:
name: parse_uri
Would return:
'http://why-not-use-a-link.uh'
Instance Method Summary collapse
- #get ⇒ String
-
#initialize(value, context) ⇒ ParseUri
constructor
A new instance of ParseUri.
Constructor Details
#initialize(value, context) ⇒ ParseUri
Returns a new instance of ParseUri.
28 29 30 31 |
# File 'lib/html2rss/attribute_post_processors/parse_uri.rb', line 28 def initialize(value, context) @value = value @config_url = context.config.url end |
Instance Method Details
#get ⇒ String
35 36 37 38 39 40 |
# File 'lib/html2rss/attribute_post_processors/parse_uri.rb', line 35 def get Html2rss::Utils.build_absolute_url_from_relative( Html2rss::Utils.sanitize_url(@value), @config_url ).to_s end |