Class: Ofdb::Movie
- Inherits:
-
Object
- Object
- Ofdb::Movie
- Defined in:
- lib/ofdb/movie.rb
Overview
Wraps a Ofdb-Movie-Page to Ruby. This Class is Lazy-Load, means that the Pages are only loaded when needed. Also the data mining is only done when needed
Instance Attribute Summary collapse
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
-
#countries ⇒ Object
Returns an Array conating the Countries this film was filmed in.
-
#genre ⇒ Object
Returns a Array containg the Genres.
-
#imdb ⇒ Object
Returns a IMDB-ID.
-
#initialize(name) ⇒ Movie
constructor
A new instance of Movie.
-
#plot ⇒ Object
Returns s String containing the Plot.
-
#poster ⇒ Object
Returns a URL to the Poster.
-
#year ⇒ Object
Returns the year this movie was Filmed in.
Constructor Details
#initialize(name) ⇒ Movie
Returns a new instance of Movie.
7 8 9 10 11 |
# File 'lib/ofdb/movie.rb', line 7 def initialize(name) @name = name @url = "http://www.ofdb.de/film/#{@name}" @title = /\d,/.match(name).post_match.gsub("---","§§§").gsub("-", " ").gsub("§§§", " - ") end |
Instance Attribute Details
#title ⇒ Object (readonly)
Returns the value of attribute title.
6 7 8 |
# File 'lib/ofdb/movie.rb', line 6 def title @title end |
Instance Method Details
#countries ⇒ Object
Returns an Array conating the Countries this film was filmed in
45 46 47 |
# File 'lib/ofdb/movie.rb', line 45 def countries get_viewphp("Kat=Land").map {|x| x.innerHTML } end |
#genre ⇒ Object
Returns a Array containg the Genres
40 41 42 |
# File 'lib/ofdb/movie.rb', line 40 def genre get_viewphp("page=genre&Genre=").map {|x| x.innerHTML } end |
#imdb ⇒ Object
Returns a IMDB-ID
14 15 16 17 18 |
# File 'lib/ofdb/movie.rb', line 14 def imdb document.search('a[@href^="http://www.imdb.com/"]').each do |x| return x.get_attribute("href").to_s.gsub("http://www.imdb.com/Title?", "") end end |
#plot ⇒ Object
Returns s String containing the Plot
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/ofdb/movie.rb', line 21 def plot document.search('a[@href^="plot/"]').each do |x| @plot_doc ||= Hpricot(open("http://www.ofdb.de/"+x.get_attribute("href"))) @plot_doc.search('//font[@class=Blocksatz]/').each do |y| #next unless y.search('a[@href="usercenter/"') next if y.to_s =~ /<b>/ || y.to_s =~ /<\/b>/ || y.to_s =~ /<br \/>/ return y.to_s.strip end end end |
#poster ⇒ Object
Returns a URL to the Poster
33 34 35 36 37 |
# File 'lib/ofdb/movie.rb', line 33 def poster document.search('img[@src^="http://img.ofdb.de/film/"]').each do |x| return x.get_attribute("src").to_s end end |
#year ⇒ Object
Returns the year this movie was Filmed in
50 51 52 |
# File 'lib/ofdb/movie.rb', line 50 def year get_viewphp("Kat=Jahr").each {|x| return x.innerHTML } end |