Class: Justiz::Scraper::Page
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Justiz::Scraper::Page
show all
- Defined in:
- lib/justiz/scraper/courts.rb
Defined Under Namespace
Classes: AddressTd, KontaktTd, Td
Instance Method Summary
collapse
Instance Method Details
71
72
73
|
# File 'lib/justiz/scraper/courts.rb', line 71
def contacts
@contacts ||= parse_contacts
end
|
#limit_warning? ⇒ Boolean
56
57
58
59
60
61
|
# File 'lib/justiz/scraper/courts.rb', line 56
def limit_warning?
search('p').find do |p|
p.text.force_encoding("ISO-8859-15") =~ /Ihre Suchanfrage ergab mehr als/i
end
end
|
#options_of(name) ⇒ Object
return hash of options of select field, exclude ALL value
64
65
66
67
68
69
|
# File 'lib/justiz/scraper/courts.rb', line 64
def options_of(name)
search("[name='#{name}'] > option").inject({}) do |memo, node|
memo[node['value']] = node.text unless node['value'] == 'ALL'
memo
end
end
|
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
# File 'lib/justiz/scraper/courts.rb', line 75
def parse_contacts
rows = search('tr').map { |tr| tr.search('td').to_a }
contact_rows = rows.find_all { |row| row.length == 3 }
contact_rows.map do |court, addresses, kontakt|
addresses = AddressTd.new(addresses)
kontakt = KontaktTd.new(kontakt)
Justiz::Contact.new(court: court.text.strip,
location: addresses.lieferanschrift,
post: addresses.postfach,
phone: kontakt.telefone,
fax: kontakt.fax,
justiz_id: kontakt.justiz_id,
url: kontakt.url,
email: kontakt.email)
end
end
|