Class: Justiz::Scraper::Courts

Inherits:
Object
  • Object
show all
Defined in:
lib/justiz/scraper/courts.rb

Instance Method Summary collapse

Instance Method Details

#contactsObject



13
14
15
16
17
18
# File 'lib/justiz/scraper/courts.rb', line 13

def contacts
  contacts = states.keys.map do |state|
    contacts_for(state)
  end.flatten.compact
  uniq_contacts(contacts)
end

#contacts_for(state) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/justiz/scraper/courts.rb', line 20

def contacts_for(state)
  page = load_page('ALL', state)
  return page.contacts unless page.limit_warning?

  # do each type separately hoping to avoid limit warning
  contacts = court_types.keys.map do |court_type|
    contacts_of_type(court_type, state)
  end.flatten.compact
  uniq_contacts(contacts)
end

#contacts_of_type(type, state) ⇒ Object



31
32
33
34
# File 'lib/justiz/scraper/courts.rb', line 31

def contacts_of_type(type, state)
  contacts = load_page(type, state, with_warning: true).contacts
  uniq_contacts(contacts)
end

#court_typesObject



5
6
7
# File 'lib/justiz/scraper/courts.rb', line 5

def court_types
  home_page.options_of 'gerausw'
end

#statesObject



9
10
11
# File 'lib/justiz/scraper/courts.rb', line 9

def states
  home_page.options_of 'landausw'
end