Sha256: 2706768e4376e2466413b0eb57766179077b40a174063d52e87a2ad2e16b6b1c

Contents?: true

Size: 810 Bytes

Versions: 10

Compression:

Stored size: 810 Bytes

Contents

module Imdb

  class MovieList
    def movies
      @movies ||= parse_movies
    end
    
    private
    def parse_movies
      document.search('a[@href^="/title/tt"]').reject do |element|
        element.innerHTML.imdb_strip_tags.empty? ||
        element.parent.innerHTML =~ /media from/i
      end.map do |element|
        id = element['href'][/\d+/]
        
        data = element.parent.innerHTML.split("<br />")
        if !data[0].nil? && !data[1].nil? && data[0] =~ /img/
          title = data[1]
        else
          title = data[0]
        end
        
        title = title.imdb_strip_tags.imdb_unescape_html
        title.gsub!(/\s+\(\d\d\d\d\)$/, '')
        
        [id, title]
      end.uniq.map do |values|
        Imdb::Movie.new(*values)
      end
    end
  end # MovieList

end # Imdb

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
cschiewek-imdb-0.5.1 lib/imdb/movie_list.rb
imdb-0.6.6 lib/imdb/movie_list.rb
imdb-0.6.5 lib/imdb/movie_list.rb
imdb-0.6.4 lib/imdb/movie_list.rb
imdb-0.6.3 lib/imdb/movie_list.rb
imdb-0.6.2 lib/imdb/movie_list.rb
imdb-0.6.1 lib/imdb/movie_list.rb
imdb-0.6.0 lib/imdb/movie_list.rb
imdb-0.5.1 lib/imdb/movie_list.rb
imdb-0.5.0 lib/imdb/movie_list.rb