Class: Tmdb::Search

Inherits:
Struct show all
Defined in:
lib/tmdb/search.rb

Class Method Summary collapse

Methods inherited from Struct

#analyze_value, #initialize

Constructor Details

This class inherits a constructor from Tmdb::Struct

Class Method Details

.collection(query, filters = {}) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/tmdb/search.rb', line 17

def self.collection(query, filters={})
  filters.merge!(query: query)

  get_result = Resource.new('/search/collection', filters).get

  result = Result.new(get_result.except('results'))
  result.results = get_result['results'].map do |movie|
    Collection.new(movie)
  end

  result
end

.company(query, filters = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/tmdb/search.rb', line 4

def self.company(query, filters={})
  filters.merge!(query: query)

  get_result = Resource.new('/search/company', filters).get

  result = Result.new(get_result.except('results'))
  result.results = get_result['results'].map do |movie|
    Company.new(movie)
  end

  result
end

.keyword(query, filters = {}) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/tmdb/search.rb', line 30

def self.keyword(query, filters={})
  filters.merge!(query: query)

  get_result = Resource.new('/search/keyword', filters).get

  result = Result.new(get_result.except('results'))
  result.results = get_result['results'].map do |movie|
    Keyword.new(movie)
  end

  result
end

.movie(query, filters = {}) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/tmdb/search.rb', line 43

def self.movie(query, filters={})
  filters.merge!(query: query)

  get_result = Resource.new('/search/movie', filters).get

  result = Result.new(get_result.except('results'))
  result.results = get_result['results'].map do |movie|
    Movie.new(movie)
  end

  result
end

.multi(query, filters = {}) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/tmdb/search.rb', line 56

def self.multi(query, filters={})
  filters.merge!(query: query)

  get_result = Resource.new('/search/multi', filters).get

  result = Result.new(get_result.except('results'))
  result.results = get_result['results'].map do |movie|
    Multi.new(movie)
  end

  result
end

.person(query, filters = {}) ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/tmdb/search.rb', line 69

def self.person(query, filters={})
  filters.merge!(query: query)

  get_result = Resource.new('/search/person', filters).get

  result = Result.new(get_result.except('results'))
  result.results = get_result['results'].map do |movie|
    person = Person.new(movie)
    person.convert_known_for!
    person
  end

  result
end

.tv(query, filters = {}) ⇒ Object



84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/tmdb/search.rb', line 84

def self.tv(query, filters={})
  filters.merge!(query: query)

  get_result = Resource.new('/search/tv', filters).get

  result = Result.new(get_result.except('results'))
  result.results = get_result['results'].map do |movie|
    TV.new(movie)
  end

  result
end