Module: SpiderCore::PaginationDSL

Included in:
MicroSpider
Defined in:
lib/spider_core/pagination_dsl.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#next_pageObject

Returns the value of attribute next_page.



4
5
6
# File 'lib/spider_core/pagination_dsl.rb', line 4

def next_page
  @next_page
end

#skip_pagesObject

Returns the value of attribute skip_pages.



4
5
6
# File 'lib/spider_core/pagination_dsl.rb', line 4

def skip_pages
  @skip_pages
end

Instance Method Details

#keep_eyes_on_next_page(pattern, attr: :href, &block) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/spider_core/pagination_dsl.rb', line 6

def keep_eyes_on_next_page(pattern, attr: :href, &block)
  actions << lambda {
    element = first(pattern)
    path = block_given? ? yield(element) : element && element[:href]
    @paths.unshift(path) if path
  }
end