Class: Sc::RootSelector

Inherits:
Selector show all
Defined in:
lib/scrappy/extractor/selectors/root.rb

Instance Method Summary collapse

Methods inherited from Selector

#select

Methods included from Scrappy::Formats

#format

Instance Method Details

#filter(doc) ⇒ Object



3
4
5
6
7
8
9
10
# File 'lib/scrappy/extractor/selectors/root.rb', line 3

def filter doc
  if sc::attribute.first
    # Select node's attribute if given
    sc::attribute.map { |attribute| { :uri=>doc[:uri], :content=>doc[:content], :value=>doc[:content][attribute], :attribute=>attribute } }
  else
    [ { :uri=>doc[:uri], :content=>doc[:content], :value=>format(doc[:value], sc::format, doc[:uri]) } ]
  end
end