Module: LCBO::CrawlKit::Crawler::InstanceMethods

Defined in:
lib/lcbo/crawlkit/crawler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#responsesObject (readonly)

Returns the value of attribute responses.



23
24
25
# File 'lib/lcbo/crawlkit/crawler.rb', line 23

def responses
  @responses
end

Instance Method Details

#continue?(response) ⇒ Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/lcbo/crawlkit/crawler.rb', line 47

def continue?(response)
  false
end

#failure(error, params) ⇒ Object



43
44
45
# File 'lib/lcbo/crawlkit/crawler.rb', line 43

def failure(error, params)
  raise error
end

#initialize(&emitter) ⇒ Object



25
26
27
28
# File 'lib/lcbo/crawlkit/crawler.rb', line 25

def initialize(&emitter)
  @emitter = emitter
  @responses = []
end

#request(params = {}) ⇒ Object



51
52
53
# File 'lib/lcbo/crawlkit/crawler.rb', line 51

def request(params = {})
  raise NotImplementedError, "#{self.class} must implement #request"
end

#run(params = {}) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/lcbo/crawlkit/crawler.rb', line 30

def run(params = {})
  case
  when params.is_a?(Array) && params.any?
    runeach(params)
  when respond_to?(:pop)
    runpop
  when respond_to?(:enum)
    runeach(enum)
  else
    _request(params)
  end
end