Class: TMDb::Person
- Inherits:
-
Object
- Object
- TMDb::Person
- Extended by:
- Attributes
- Defined in:
- lib/tmdb/person.rb
Class Method Summary collapse
-
.find(id) ⇒ Object
Returns the person with TMDb id of
id
. -
.where(args) ⇒ Object
Returns an enumerable containing all the people matching the condition hash.
Instance Method Summary collapse
-
#initialize(args) ⇒ Person
constructor
A new instance of Person.
-
#profile_image_url(size) ⇒ Object
Returns a URL for the person’s profile image at the given
size
.
Methods included from Attributes
Constructor Details
#initialize(args) ⇒ Person
Returns a new instance of Person.
19 20 21 |
# File 'lib/tmdb/person.rb', line 19 def initialize(args) @tmdb_attrs = args end |
Class Method Details
.find(id) ⇒ Object
Returns the person with TMDb id of id
.
25 26 27 28 29 30 31 32 |
# File 'lib/tmdb/person.rb', line 25 def self.find(id) begin response = TMDb.get_api_response("person/#{id}") new(response) rescue ServiceUnavailable TMDb.configuration.null_person || raise end end |
.where(args) ⇒ Object
Returns an enumerable containing all the people matching the condition hash. Currently the only condition that can be specified is name, e.g.
people = Person.where(:name => 'Reeves')
Only the first page of results (20 people) are returned.
42 43 44 45 |
# File 'lib/tmdb/person.rb', line 42 def self.where(args) response = TMDb.get_api_response('search/person', :query => args[:name]) response['results'].map {|attrs| new(attrs) } end |
Instance Method Details
#profile_image_url(size) ⇒ Object
Returns a URL for the person’s profile image at the given size
. Valid sizes should be discovered via the Configuration.image_profile_sizes
method. Returns nil if the person does not have a profile image.
51 52 53 54 55 |
# File 'lib/tmdb/person.rb', line 51 def profile_image_url(size) if profile_path [TMDb.configuration.image_base_url, size, profile_path].join end end |