Sha256: bd1234d422a1bc204c2581e06dc3f4c6da8d57687e2727f90c8febc1f36e9f1a

Contents?: true

Size: 621 Bytes

Versions: 2

Compression:

Stored size: 621 Bytes

Contents

# frozen_string_literal: true

require 'aranha/parsers/html/base'

module Aranha
  module Parsers
    module Html
      class ItemList < Base
        def data
          items_data
        end

        def items_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

2 entries across 2 versions & 1 rubygems

Version Path
aranha-parsers-0.2.1 lib/aranha/parsers/html/item_list.rb
aranha-parsers-0.2.0 lib/aranha/parsers/html/item_list.rb