Class: Sc::SliceSelector

Inherits:
Selector show all
Defined in:
lib/scrappy/extractor/selectors/slice.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/slice.rb', line 3

def filter doc
  rdf::value.map do |separator|
    slices = doc[:value].split(separator)
    sc::index.map { |index| slices[index.to_i].to_s.strip }.
              select { |value| value != "" }.
              map { |value| { :uri=>doc[:uri], :content=>doc[:content], :value=>value, :attribute=>doc[:attribute]} }
  end.flatten
end