Sha256: be43704b7a4307c3193e086870992c21c9fcc118dfbeb2571767daa0f9f9f963

Contents?: true

Size: 1.5 KB

Versions: 1

Compression:

Stored size: 1.5 KB

Contents

# frozen_string_literal: true

module Weneedfeed
  class Page
    # @return [String, nil]
    attr_reader :description

    # @return [String]
    attr_reader :title

    # @return [String]
    attr_reader :url

    # @param [String, nil] description
    # @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(
      description:,
      item_description_selector:,
      item_link_selector:,
      item_time_selector:,
      item_title_selector:,
      item_selector:,
      node:,
      title:,
      url:
    )
      @description = description
      @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

1 entries across 1 versions & 1 rubygems

Version Path
weneedfeed-0.8.0 lib/weneedfeed/page.rb