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, #nokogiri

Methods inherited from Base

#content, from_content, #initialize, parse_content

Constructor Details

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

Instance Method Details

#dataObject



9
10
11
# File 'lib/aranha/parsers/html/item_list.rb', line 9

def data
  items_data
end

#item_data(item) ⇒ Object



13
14
15
# File 'lib/aranha/parsers/html/item_list.rb', line 13

def item_data(item)
  item
end

#items_dataObject



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

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



27
28
29
# File 'lib/aranha/parsers/html/item_list.rb', line 27

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