Module: TMDb::Searchable

Included in:
Movie
Defined in:
lib/tmdb/searchable.rb

Instance Method Summary collapse

Instance Method Details

#resourceObject

Removes the module part from the expression in the string.



29
30
31
# File 'lib/tmdb/searchable.rb', line 29

def resource
  name.split('::').last.downcase || ''
end

#search(query, options = {}) ⇒ Object

Search movies.

query - Query string that will be matched with the movie name. options - The hash options used to filter the search (default: {}):

:page - The current page of results.
:language - Language of the result data (ISO 639-1 codes) (default: en).
:include_adult - Toggle the inclusion of adult titles. Expected value is: true or false.
:year - Filter results to only include this value.

Examples

TMDb::Movie.search(‘Iron Man’)

TMDb::Movie.search(‘The Matrix’, year: 1999)

TMDb::Movie.search(‘Forret Gump’, language: ‘pt’, year: 1994)



21
22
23
24
25
26
# File 'lib/tmdb/searchable.rb', line 21

def search(query, options = {})
  # require "pry"; binding.pry
  options.merge!(query: query)
  result = Fetcher::get("/search/#{resource}", options)
  result['results'].map { |attributes| new(attributes) }
end