Sha256: e2a0b09e5a79d0d634b993f7c327fdc05c9638be7cf183015a5669ff27f3694f
Contents?: true
Size: 1.14 KB
Versions: 1
Compression:
Stored size: 1.14 KB
Contents
# frozen_string_literal: true module Html2rss module AttributePostProcessors ## # 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' class ParseUri < Base def self.validate_args!(value, context) url_types = [String, URI::HTTP, Addressable::URI].freeze assert_type(value, url_types, :value) assert_type(context.config.url, url_types, :url) raise ArgumentError, 'The `value` option is missing or empty.' if value.to_s.empty? end ## # @return [String] def get config_url = context.config.url Html2rss::Utils.build_absolute_url_from_relative( Html2rss::Utils.sanitize_url(value), config_url ).to_s end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
html2rss-0.12.0 | lib/html2rss/attribute_post_processors/parse_uri.rb |