Module: Kijkwijzer
- Defined in:
- lib/kijkwijzer.rb,
lib/kijkwijzer/result.rb,
lib/kijkwijzer/railtie.rb,
lib/kijkwijzer/version.rb,
lib/kijkwijzer/view_helpers.rb
Defined Under Namespace
Modules: ViewHelpers
Classes: Railtie, Result
Constant Summary
collapse
- VERSION =
"0.1.0"
Class Method Summary
collapse
Class Method Details
.get_content(search) ⇒ Object
13
14
15
|
# File 'lib/kijkwijzer.rb', line 13
def get_content(search)
Nokogiri::HTML(open(search_url(search)))
end
|
.search(search, filter = {}) ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/kijkwijzer.rb', line 16
def search(search, filter={})
res = get_content(search)
results = []
res.css('.content_hok .nieuwsitem').each do |result|
r = Result.new()
r.title = result.css('b').text
meta_parse = result.text.match(/Productietype\:\s(.*)\.\sProductiejaar\:\s(\d\d\d\d)\.\s/)
r.year = meta_parse[2].to_i
r.production_type = meta_parse[1]
r.ratings = result.css("img").collect{|a| a.attr("src").match(/\/images\/icons\/M_(.*)\.png/)[1]}
include_r = true
filter.each do |key, value|
include_r = (r.send(key) == value)
end
results << r if include_r
end
results
end
|
.search_url(search) ⇒ Object
10
11
12
|
# File 'lib/kijkwijzer.rb', line 10
def search_url(search)
"http://www.kijkwijzer.nl/index.php?id=3__i&searchfor=#{url_encode(search)}&tab=KIJKWIJZER"
end
|