Class: Imdb::Search

Inherits:
MovieList show all
Defined in:
lib/imdb/search.rb

Overview

Search IMDB for a title

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(query) ⇒ Search

Initialize a new IMDB search with the specified query

search = Imdb::Search.new("Star Trek")

Imdb::Search is lazy loading, meaning that unless you access the movies attribute, no query is made to IMDB.com.



14
15
16
# File 'lib/imdb/search.rb', line 14

def initialize(query)
  @query = query
end

Instance Attribute Details

#queryObject (readonly)

Returns the value of attribute query.



5
6
7
# File 'lib/imdb/search.rb', line 5

def query
  @query
end

Instance Method Details

#moviesObject

Returns an array of Imdb::Movie objects for easy search result yielded. If the query was an exact match, a single element array will be returned.



20
21
22
# File 'lib/imdb/search.rb', line 20

def movies
  @movies ||= (exact_match? ? parse_movie : parse_movies)
end