Class: TMDBParty::Base

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/tmdb_party.rb

Instance Method Summary collapse

Constructor Details

#initialize(key) ⇒ Base

Returns a new instance of Base.



17
18
19
# File 'lib/tmdb_party.rb', line 17

def initialize(key)
  self.class.default_params :api_key => key
end

Instance Method Details

#get_info(id) ⇒ Object



44
45
46
47
# File 'lib/tmdb_party.rb', line 44

def get_info(id)
  data = self.class.get('/Movie.getInfo', :query=>{:id=>id})
  Movie.new(data['results']['moviematches']['movie'], self)
end

#imdb_lookup(imdb_id) ⇒ Object



34
35
36
37
38
39
40
41
42
# File 'lib/tmdb_party.rb', line 34

def imdb_lookup(imdb_id)
  data = self.class.get('/Movie.imdbLookup', :query=>{:imdb_id=>imdb_id})
  case data['results']['moviematches']['movie']
  when String
    return nil
  when Hash
    Movie.new(data['results']['moviematches']['movie'], self)
  end
end

#search(query) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/tmdb_party.rb', line 21

def search(query)
  data = self.class.get('/Movie.search', :query=>{:title=>query})
  
  case data['results']['moviematches']['movie']
  when Array
    data['results']['moviematches']['movie'].collect { |movie| Movie.new(movie, self) }
  when Hash
    [Movie.new(data['results']['moviematches']['movie'], self)]
  else
    []
  end
end