Class: Kijkwijzer::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/kijkwijzer/result.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#production_typeObject

Returns the value of attribute production_type.



4
5
6
# File 'lib/kijkwijzer/result.rb', line 4

def production_type
  @production_type
end

#ratingsString

Get the ratings for the result

Returns:

  • (String)

    with kijkwijzer-ratings (English-language-labels)



11
12
13
# File 'lib/kijkwijzer/result.rb', line 11

def ratings
  @ratings
end

#titleObject

Returns the value of attribute title.



3
4
5
# File 'lib/kijkwijzer/result.rb', line 3

def title
  @title
end

#yearObject

Returns the value of attribute year.



5
6
7
# File 'lib/kijkwijzer/result.rb', line 5

def year
  @year
end

Class Method Details

.new_from_nokogiri_result_fragment(nokogiri_result_fragment) ⇒ Object



34
35
36
37
38
39
40
41
42
43
# File 'lib/kijkwijzer/result.rb', line 34

def new_from_nokogiri_result_fragment nokogiri_result_fragment
  r = self.new
  r.title = nokogiri_result_fragment.css('b').text
  production_type_match = nokogiri_result_fragment.text.match(/Productietype\:\s(.*)\.(\sProductie)/)
  production_year_match = nokogiri_result_fragment.text.match(/\sProductiejaar\:\s(\d\d\d\d)\.\s/)
  r.year = production_year_match[1].to_i if production_year_match
  r.production_type = production_type_match[1] if production_type_match
  r.ratings = nokogiri_result_fragment.css("img").collect{|a| a.attr("src").match(/\/upload\/pictogrammen\/\d*_\d*_(.*)\.png/)[1]}
  return r
end

Instance Method Details

#match_filter?(filter) ⇒ TrueClass, FalseClass

Filters use a key value hash to which the results should conform

Returns:

  • (TrueClass, FalseClass)


29
30
31
# File 'lib/kijkwijzer/result.rb', line 29

def match_filter?(filter)
  !(filter.collect{|k, v| include_r = (self.send(k) == v)}.include? false)
end

#to_sObject



22
23
24
# File 'lib/kijkwijzer/result.rb', line 22

def to_s
  "#<Kijkwijzer::Result @title=\"#{title}\", @year=#{year}>"
end