class Imdb::Search

Constants

TYPES

Attributes

type[R]

Public Class Methods

new(query, type = nil) click to toggle source
# File lib/imdb/imdb.rb, line 12
def initialize(query, type = nil)
  @query = query
  @type  = type
end

Private Instance Methods

document() click to toggle source
# File lib/imdb/imdb.rb, line 19
def document
  @document ||= Nokogiri::HTML(submit_query)
end
submit_query() click to toggle source
# File lib/imdb/imdb.rb, line 23
def submit_query
  url = "http://akas.imdb.com/find?q=#{CGI.escape(query)}&s=tt"
  url << "&ttype=#{TYPES[type]}" if type && TYPES.include?(type)
  open(url)
end