Skip to main content

Ruby Gem: IMDB

·200 words·1 min· ·
General Ruby Imdb Gem Api
Ariejan de Vroom
Author
Ariejan de Vroom
Jack of all Trades, Professional Software Craftsman
Table of Contents

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
#

sudo gem install imdb

This will also install the dependencies Hpricot and HTTParty.

Usage
#

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

require 'rubygems'
require 'imdb'

search = Imdb::Search.new('Star Trek')
=> #<Imdb::Search:0x18289e8 @query="Star Trek">

puts search.movies[0..3].collect{ |m| [m.id, m.title].join(" - ") }.join("\n")
=> 0060028 - "Star Trek" (1966) (TV series)
        0796366 - Star Trek (2009)
        0092455 - "Star Trek: The Next Generation" (1987) (TV series)
        0112178 - "Star Trek: Voyager" (1995) (TV series)

st = Imdb::Movie.new("0796366")
=> #<Imdb::Movie:0x16ff904 @url="http://www.imdb.com/title/tt0796366/", @id="0796366", @title=nil>

st.title
=> "Star Trek"
st.year
=> 2009
st.rating
=> 8.4
st.cast_members[0..2].join(", ")
=> "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.

Related

warcraft-armory 0.1.0 Released
·94 words·1 min
General Ruby Warcraft-Armory Rubygems
RSpec'ing with Time.now
·174 words·1 min
General Ruby Rails Rspec Test Time
BaseApp: a quick start for your Rails App
·303 words·2 mins
General Ruby Ruby on Rails Rails BaseApp