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.



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

def initialize(query)
  @query = query
end

Instance Attribute Details

#queryObject (readonly)

Returns the value of attribute query



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

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.



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

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