Class: Enceladus::ProductionCompany
- Inherits:
-
ApiResource
- Object
- ApiResource
- Enceladus::ProductionCompany
- Defined in:
- lib/enceladus/models/production_company.rb
Constant Summary collapse
- RESOURCE_ATTRIBUTES =
[:id, :logo_path, :name, :description, :headquarters, :homepage].map(&:freeze).freeze
Class Method Summary collapse
-
.find(id) ⇒ Object
Finds a production company by id.
-
.find_by_name(name) ⇒ Object
Returns a paginated collection of ProductionCompanies with the name.
Instance Method Summary collapse
-
#logo_urls ⇒ Object
Returns an array containing URL’s (as string) for the companies logos.
-
#movies ⇒ Object
Returns a paginated collection of all movies of a production company.
-
#reload ⇒ Object
Fetchs for more details about the production company.
Class Method Details
.find(id) ⇒ Object
Finds a production company by id. Example:
company = Enceladus::ProductionCompany.find(7505)
16 17 18 |
# File 'lib/enceladus/models/production_company.rb', line 16 def self.find(id) build_single_resource(Enceladus::Requester.get("company/#{id}", default_params)) end |
.find_by_name(name) ⇒ Object
Returns a paginated collection of ProductionCompanies with the name. Example:
Enceladus::ProductionCompany.find_by_name("Marvel")
9 10 11 |
# File 'lib/enceladus/models/production_company.rb', line 9 def self.find_by_name(name) Enceladus::ProductionCompanyCollection.new("search/company", { query: name }) end |
Instance Method Details
#logo_urls ⇒ Object
Returns an array containing URL’s (as string) for the companies logos.
21 22 23 |
# File 'lib/enceladus/models/production_company.rb', line 21 def logo_urls Enceladus::Configuration::Image.instance.url_for("logo", logo_path) end |
#movies ⇒ Object
Returns a paginated collection of all movies of a production company. Example:
marvel = Enceladus::ProductionCompany.find(7505)
marvel.movies
=> [Movie(@title="Thor"), Movie(@title="Captain America"), Movie(@title="Iron Man")]
42 43 44 |
# File 'lib/enceladus/models/production_company.rb', line 42 def movies Enceladus::MovieCollection.new("company/#{id}/movies", Enceladus::Movie.default_params) end |
#reload ⇒ Object
Fetchs for more details about the production company. Example:
marvel = Enceladus::ProductionCompany.find_by_name("marvel").last
=> #<Enceladus::ProductionCompany @id=325, @logo_path="/pic.png", @name="Marvel Entertainment, LLC">
marvel.reload
=> #<Enceladus::ProductionCompan @id=325, @logo_path="/pic.png", @name="Marvel Entertainment, LLC", @description=nil, @headquarters="New York, New York, USA", @homepage="http://www.marvel.com">
32 33 34 |
# File 'lib/enceladus/models/production_company.rb', line 32 def reload rebuild_single_resource(Enceladus::Requester.get("company/#{id}", self.class.default_params)) end |