Class: Traktr::Search
Instance Method Summary collapse
-
#episodes(query) ⇒ Object
search GET methods.
-
#initialize(client) ⇒ Search
constructor
A new instance of Search.
- #movies(query) ⇒ Object
- #people(query) ⇒ Object
- #shows(query, limit = 30, seasons = nil) ⇒ Object
- #users(query) ⇒ Object
Constructor Details
#initialize(client) ⇒ Search
Returns a new instance of Search.
6 7 8 |
# File 'lib/traktr/search.rb', line 6 def initialize(client) @client = client end |
Instance Method Details
#episodes(query) ⇒ Object
search GET methods
13 14 15 16 17 18 19 20 |
# File 'lib/traktr/search.rb', line 13 def episodes(query) response = self.class.get('/' + File.join('episodes.json', @client.api_key, URI::encode(query))) raise ResponseError.new(response) if response.code != 200 response.parsed_response.collect do |result| Mash.new(result) end end |
#movies(query) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/traktr/search.rb', line 22 def movies(query) response = self.class.get('/' + File.join('movies.json', @client.api_key, URI::encode(query))) raise ResponseError.new(response) if response.code != 200 response.parsed_response.collect do |result| Mash.new(result) end end |
#people(query) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/traktr/search.rb', line 31 def people(query) response = self.class.get('/' + File.join('people.json', @client.api_key, URI::encode(query))) raise ResponseError.new(response) if response.code != 200 response.parsed_response.collect do |result| Mash.new(result) end end |
#shows(query, limit = 30, seasons = nil) ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/traktr/search.rb', line 40 def shows(query, limit = 30, seasons = nil) response = self.class.get('/' + File.join('shows.json', @client.api_key, URI::encode(query), limit.to_s, seasons.to_s)) raise ResponseError.new(response) if response.code != 200 response.parsed_response.collect do |result| Mash.new(result) end end |
#users(query) ⇒ Object
49 50 51 52 53 54 55 56 |
# File 'lib/traktr/search.rb', line 49 def users(query) response = self.class.get('/' + File.join('users.json', @client.api_key, URI::encode(query))) raise ResponseError.new(response) if response.code != 200 response.parsed_response.collect do |result| Mash.new(result) end end |