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
# File 'lib/justiz/scraper/courts.rb', line 13

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

#contacts_for(state) ⇒ Object



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

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
  court_types.keys.map do |court_type|
    contacts_of_type(court_type, state)
  end.flatten.compact.uniq
end

#contacts_of_type(type, state) ⇒ Object



29
30
31
# File 'lib/justiz/scraper/courts.rb', line 29

def contacts_of_type(type, state)
  load_page(type, state, with_warning: true).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