Class: TMDb::Person

Inherits:
Base
  • Object
show all
Extended by:
Searchable
Defined in:
lib/tmdb-api/person.rb

Constant Summary collapse

ATTRIBUTES =
:id, :adult, :also_known_as, :biography, :homepage, :name,
:place_of_birth, :profile_path, :popularity, :imdb_id, :known_for

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Searchable

search

Methods inherited from Base

bad_response, #initialize

Constructor Details

This class inherits a constructor from TMDb::Base

Class Method Details

.find(id, options = {}) ⇒ Object

Public: Gets the basic person information for a specific person ID.

id - The ID of the person. options - The hash options used to filter the search (default: {}):

More information about the options, check the api documentation

Examples

TMDb::Person.find(138)


19
20
21
22
# File 'lib/tmdb-api/person.rb', line 19

def self.find(id, options = {})
  res = get("/person/#{id}", query: options)
  res.success? ? Person.new(res) : bad_response(res)
end

.images(id) ⇒ Object

Public: Gets the images for a specific person ID.

id - The person’s ID

Examples

TMDb::Person.images(138)


31
32
33
34
# File 'lib/tmdb-api/person.rb', line 31

def self.images(id)
  res = get("/person/#{id}/images")
  res.success? ? res : bad_response(res)
end

Public: Gets a list of popular people.

options - The hash options used to filter the search (default: {}):

:page - List's page.

Examples

TMDb::Person.popular
TMDb::Person.popular(page: 4)


45
46
47
48
49
50
51
52
53
# File 'lib/tmdb-api/person.rb', line 45

def self.popular(options = {})
  res = get('/person/popular', query: options)

  if res.success?
    res['results'].map { |person| Person.new(person) }
  else
    bad_response(res)
  end
end

Instance Method Details

#birthdayObject

Public: return the parsed birthday.



56
57
58
# File 'lib/tmdb-api/person.rb', line 56

def birthday
  Date.parse(@birthday) rescue nil
end

#deathdayObject

Public: return the parsed deathday.



61
62
63
# File 'lib/tmdb-api/person.rb', line 61

def deathday
  Date.parse(@deathday) rescue nil
end