Sha256: 71b3d32bfc5107a3520c625c82bfcdd1a2243f89967f302926ce61c66fcd510b

Contents?: true

Size: 407 Bytes

Versions: 3

Compression:

Stored size: 407 Bytes

Contents

# frozen_string_literal: true

require 'nokogiri'
require 'url_finder/readers/base_reader'

module UrlFinder
  # Find URLs in HTML strings
  class HTMLReader < BaseReader
    # Returns the found URLs
    # @return [Array<String>] the found URLs
    def urls
      @urls ||= begin
        document = Nokogiri::HTML(content)
        document.css('a').map { |e| e['href'] }.compact
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
url_finder-0.2.2 lib/url_finder/readers/html_reader.rb
url_finder-0.2.1 lib/url_finder/readers/html_reader.rb
url_finder-0.2.0 lib/url_finder/readers/html_reader.rb