Class: Aranha::Parsers::Html::ItemList

Inherits:
Base
  • Object
show all
Defined in:
lib/aranha/parsers/html/item_list.rb

Constant Summary

Constants inherited from Base

Base::LOG_DIR_ENVVAR

Instance Attribute Summary

Attributes inherited from Base

#source_address

Instance Method Summary collapse

Methods inherited from Base

field, fields, from_node, #nokogiri, xpath_contains_class, xpath_ends_with

Methods inherited from Base

#content, #content_encoding, from_content, from_string, #initialize, #source_address_content

Constructor Details

This class inherits a constructor from Aranha::Parsers::Base

Instance Method Details

#dataObject



7
8
9
# File 'lib/aranha/parsers/html/item_list.rb', line 7

def data
  items_data
end

#item_data(item) ⇒ Object



11
12
13
# File 'lib/aranha/parsers/html/item_list.rb', line 11

def item_data(item)
  item
end

#items_dataObject



15
16
17
18
19
20
21
22
23
# File 'lib/aranha/parsers/html/item_list.rb', line 15

def items_data
  count = 0
  @data ||= nokogiri.xpath(items_xpath).map do |m|
    count += 1
    item_data(node_parser.parse(m))
  end
rescue StandardError => e
  raise StandardError, "#{e.message} (Count: #{count})"
end

#items_xpathObject



25
26
27
# File 'lib/aranha/parsers/html/item_list.rb', line 25

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