Sha256: f30181727115112d54474051bd9f4dc9b089078dc6842f1db40814b52954efb2

Contents?: true

Size: 1.35 KB

Versions: 5

Compression:

Stored size: 1.35 KB

Contents

# frozen_string_literal: true

module Weneedfeed
  class Page
    # @return [String]
    attr_reader :title

    # @return [String]
    attr_reader :url

    # @param [String, nil] item_description_selector
    # @param [String] item_link_selector
    # @param [String, nil] item_time_selector
    # @param [String] item_title_selector
    # @param [String] item_selector
    # @param [Nokogiri::Node] node
    # @param [String] title
    # @param [String] url
    def initialize(
      item_description_selector:,
      item_link_selector:,
      item_time_selector:,
      item_title_selector:,
      item_selector:,
      node:,
      title:,
      url:
    )
      @item_description_selector = item_description_selector
      @item_link_selector = item_link_selector
      @item_time_selector = item_time_selector
      @item_title_selector = item_title_selector
      @item_selector = item_selector
      @node = node
      @title = title
      @url = url
    end

    # @return [Array<Weneedfeed::Item>]
    def items
      @node.search(@item_selector).map do |node|
        ::Weneedfeed::Item.new(
          description_selector: @item_description_selector,
          link_selector: @item_link_selector,
          node: node,
          time_selector: @item_time_selector,
          title_selector: @item_title_selector,
          url: @url
        )
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
weneedfeed-0.7.2 lib/weneedfeed/page.rb
weneedfeed-0.7.1 lib/weneedfeed/page.rb
weneedfeed-0.7.0 lib/weneedfeed/page.rb
weneedfeed-0.6.1 lib/weneedfeed/page.rb
weneedfeed-0.6.0 lib/weneedfeed/page.rb