class Scraprr::ObjectScraper

Attributes

attributes[R]

Public Class Methods

new() click to toggle source
# File lib/scraprr/object_scraper.rb, line 5
def initialize
  @attributes = Set.new
end

Public Instance Methods

attribute(name, path=AttributeScraper::DEFAULT_PATH, opts={}) click to toggle source
# File lib/scraprr/object_scraper.rb, line 9
def attribute(name, path=AttributeScraper::DEFAULT_PATH, opts={})
  @attributes.add(AttributeScraper.new(name, path, opts))
  self
end
extract(node) click to toggle source
# File lib/scraprr/object_scraper.rb, line 14
def extract(node)
  attributes.reduce({}) do |item, attribute_scraper|
    element = node.search(attribute_scraper.path)
    item[attribute_scraper.name] = attribute_scraper.extract(element)
    item
  end
end