Class: Mbanker::PersistentCrawler

Inherits:
Object
  • Object
show all
Defined in:
lib/mbanker/persistent_crawler.rb

Instance Method Summary collapse

Constructor Details

#initialize(crawler, authenticater) ⇒ PersistentCrawler

Returns a new instance of PersistentCrawler.



4
5
6
7
8
9
# File 'lib/mbanker/persistent_crawler.rb', line 4

def initialize crawler, authenticater
  @crawler, @authenticator = crawler, authenticater
  if @authenticator.authenticated?
    @authenticator.authenticate!
  end
end

Instance Method Details

#can_find?(selector) ⇒ Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/mbanker/persistent_crawler.rb', line 31

def can_find? selector
  @crawler.can_find? selector
end

#click(link_or_button) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/mbanker/persistent_crawler.rb', line 19

def click link_or_button
  @crawler.click link_or_button
  unless @authenticator.session_error_absent?
    @authenticator.authenticate!
    @crawler.visit link_or_button
  end
end

#extract_text(selector) ⇒ Object



39
40
41
# File 'lib/mbanker/persistent_crawler.rb', line 39

def extract_text selector
  @crawler.extract_text selector
end

#extract_texts(selector) ⇒ Object



43
44
45
# File 'lib/mbanker/persistent_crawler.rb', line 43

def extract_texts selector
  @crawler.extract_texts selector
end

#find_first(selector) ⇒ Object



35
36
37
# File 'lib/mbanker/persistent_crawler.rb', line 35

def find_first selector
  @crawler.find_first selector
end

#get_formObject



47
48
49
# File 'lib/mbanker/persistent_crawler.rb', line 47

def get_form
  @crawler.get_form
end

#search(selector) ⇒ Object



27
28
29
# File 'lib/mbanker/persistent_crawler.rb', line 27

def search selector
  @crawler.search selector
end

#visit(path_name) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/mbanker/persistent_crawler.rb', line 11

def visit path_name
  @crawler.visit path_name
  unless @authenticator.session_error_absent?
    @authenticator.authenticate!
    @crawler.visit path_name
  end
end