Class: Html2rss::Selectors::PostProcessors::ParseUri
- Defined in:
- lib/html2rss/selectors/post_processors/parse_uri.rb
Overview
Returns the normalized URL as a String. If the URL is relative, it resolves it against the channel URL.
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 Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Base
assert_type, expect_options, #initialize
Constructor Details
This class inherits a constructor from Html2rss::Selectors::PostProcessors::Base
Class Method Details
.validate_args!(value, _context) ⇒ void
This method returns an undefined value.
29 30 31 |
# File 'lib/html2rss/selectors/post_processors/parse_uri.rb', line 29 def self.validate_args!(value, _context) raise ArgumentError, 'The `value` option is missing or empty.' if value.to_s.empty? end |
Instance Method Details
#get ⇒ String
35 36 37 38 39 |
# File 'lib/html2rss/selectors/post_processors/parse_uri.rb', line 35 def get config_url = context.dig(:config, :channel, :url) Url.from_relative(value, config_url).to_s end |