Class: OMDB::Client
Overview
Client for handling requests to the omdbapi.com API.
Instance Method Summary collapse
-
#id(imdb_id, options = {}) ⇒ Hash
Retrieves a movie or show based on its IMDb ID.
-
#search(title) ⇒ Array, Hash
(also: #find)
Search for a movie by its title.
-
#title(title, options = {}) ⇒ Hash
Retrieves a movie or show based on its title.
Instance Method Details
#id(imdb_id, options = {}) ⇒ Hash
Retrieves a movie or show based on its IMDb ID.
40 41 42 43 44 |
# File 'lib/omdbapi/client.rb', line 40 def id(imdb_id, = {}) params = { i: imdb_id } params[:tomatoes] = [:tomatoes] if [:tomatoes] get '/', params end |
#search(title) ⇒ Array, Hash Also known as: find
Search for a movie by its title.
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/omdbapi/client.rb', line 52 def search(title) results = get '/', { s: title } if results[:search] # Return the title if there is only one result, otherwise return the seach results search = results.search search.size == 1 ? title(search[0].title) : search else results end end |
#title(title, options = {}) ⇒ Hash
Retrieves a movie or show based on its title.
23 24 25 26 27 28 29 30 31 |
# File 'lib/omdbapi/client.rb', line 23 def title(title, = {}) params = { t: title } params[:y] = [:year] if [:year] params[:plot] = [:plot] if [:plot] params[:season] = [:season] if [:season] params[:episode] = [:episode] if [:episode] params[:tomatoes] = [:tomatoes] if [:tomatoes] get '/', params end |