Last updated

Ruby Gem: IMDB

I just released version 0.1.0 of my IMDB gem which allows your app to search IMDB for IMDB movie ID’s and access most data that’s publicly available.

Installation

1sudo gem install imdb

This will also install the dependencies Hpricot and HTTParty.

Usage

In your project, include the gem (and possibly rubygems as well).

 1require 'rubygems'
 2require 'imdb'
 3
 4search = Imdb::Search.new('Star Trek')
 5=> #<Imdb::Search:0x18289e8 @query="Star Trek">
 6
 7puts search.movies[0..3].collect{ |m| [m.id, m.title].join(" - ") }.join("\n")
 8=> 0060028 - "Star Trek" (1966) (TV series)
 9        0796366 - Star Trek (2009)
10        0092455 - "Star Trek: The Next Generation" (1987) (TV series)
11        0112178 - "Star Trek: Voyager" (1995) (TV series)
12
13st = Imdb::Movie.new("0796366")
14=> #<Imdb::Movie:0x16ff904 @url="http://www.imdb.com/title/tt0796366/", @id="0796366", @title=nil>
15
16st.title
17=> "Star Trek"
18st.year
19=> 2009
20st.rating
21=> 8.4
22st.cast_members[0..2].join(", ")
23=> "Chris Pine, Zachary Quinto, Leonard Nimoy"

As you can see, both Imdb::Search and Imdb::Movie are lazy loading, only doing a HTTP request when you actually request data. Also, the remote HTTP data is cached trhough-out the life span of your Imdb::Movie object.

Documentation

Generated RDoc documentation can be found at http://ariejan.github.com/imdb/.

Issues, feature requests, patches, the works

Please use https://github.com/ariejan/imdb to supply patches (preferably through a pull-request) and to report issues.