Module: TMDb::Searchable
- Included in:
- Movie
- Defined in:
- lib/tmdb/searchable.rb
Instance Method Summary collapse
-
#resource ⇒ Object
Removes the module part from the expression in the string.
-
#search(query, options = {}) ⇒ Object
Search movies.
Instance Method Details
#resource ⇒ Object
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, = {}) # require "pry"; binding.pry .merge!(query: query) result = Fetcher::get("/search/#{resource}", ) result['results'].map { |attributes| new(attributes) } end |