Sha256: 2066cb1587d179cc9b4ac79b70bc5d949c5c6396af3babbf4a7963d9ffe9c45c

Contents?: true

Size: 564 Bytes

Versions: 5

Compression:

Stored size: 564 Bytes

Contents

# frozen_string_literal: true

require 'aranha/parsers/html/base'

module Aranha
  module Parsers
    module Html
      class ItemList < Base
        def data
          count = 0
          @data ||= nokogiri.xpath(items_xpath).map do |m|
            count += 1
            node_parser.parse(m)
          end
        rescue StandardError => e
          raise StandardError, "#{e.message} (Count: #{count})"
        end

        def items_xpath
          raise "Class #{self.class} has no method \"item_xpath\". Implement it"
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
aranha-parsers-0.1.1 lib/aranha/parsers/html/item_list.rb
aranha-parsers-0.1.0 lib/aranha/parsers/html/item_list.rb
aranha-0.10.1 lib/aranha/parsers/html/item_list.rb
aranha-0.10.0 lib/aranha/parsers/html/item_list.rb
aranha-0.9.1 lib/aranha/parsers/html/item_list.rb