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.
18 19 20 |
# File 'lib/tmdb/person.rb', line 18 def initialize(args) @tmdb_attrs = args end |
Class Method Details
.find(id) ⇒ Object
Returns the person with TMDb id of id.
24 25 26 27 |
# File 'lib/tmdb/person.rb', line 24 def self.find(id) response = TMDb.get_api_response("person/#{id}") new(response) 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.
37 38 39 40 |
# File 'lib/tmdb/person.rb', line 37 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.
46 47 48 49 50 |
# File 'lib/tmdb/person.rb', line 46 def profile_image_url(size) if profile_path [TMDb.configuration.image_base_url, size, profile_path].join end end |