Class: TomatoPower::Movie
- Inherits:
-
Object
- Object
- TomatoPower::Movie
- Defined in:
- lib/tomato_power/movie/movie.rb
Overview
A Movie
Constant Summary collapse
- MOVIE_METHOD_ALIAS =
Aliased API methods for a better interface.
{ :info => :movie_info, :full_cast => :movie_cast, :clips => :movie_clips, :reviews => :movie_reviews, :similar => :movie_similar, }
Instance Attribute Summary collapse
-
#alternate_ids ⇒ Object
readonly
Returns the value of attribute alternate_ids.
-
#critics_consensus ⇒ Object
readonly
Returns the value of attribute critics_consensus.
-
#directors ⇒ Object
readonly
Returns the value of attribute directors.
-
#genres ⇒ Object
readonly
Returns the value of attribute genres.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#info ⇒ Object
readonly
Returns the value of attribute info.
-
#links ⇒ Object
readonly
Returns the value of attribute links.
-
#mpaa_rating ⇒ Object
readonly
Returns the value of attribute mpaa_rating.
-
#ratings ⇒ Object
readonly
Returns the value of attribute ratings.
-
#release_dates ⇒ Object
readonly
Returns the value of attribute release_dates.
-
#runtime ⇒ Object
readonly
Returns the value of attribute runtime.
-
#studio ⇒ Object
readonly
Returns the value of attribute studio.
-
#synopsis ⇒ Object
readonly
Returns the value of attribute synopsis.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#year ⇒ Object
readonly
Returns the value of attribute year.
Class Method Summary collapse
-
.define_movie_methods(*methods) ⇒ Object
Defines methods that are in MOVIE_METHOD_ALIAS.
Instance Method Summary collapse
-
#cast ⇒ Object
cast from a movie.
-
#initialize(movie = {}) ⇒ Movie
constructor
A new instance of Movie.
-
#posters ⇒ Object
Poster for a movie.
Constructor Details
#initialize(movie = {}) ⇒ Movie
Returns a new instance of Movie.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/tomato_power/movie/movie.rb', line 9 def initialize movie={} @id = movie["id"] @title = movie["title"] @year = movie["year"] @genres = movie["genres"] @critics_consensus = movie["critics_consensus"] @mpaa_rating = movie["mpaa_rating"] @runtime = movie["runtime"] @release_dates = movie["release_dates"] @ratings = movie["ratings"] @synopsis = movie["synopsis"] @posters = movie["posters"] @abridged_cast = movie["abridged_cast"] @alternate_ids = movie["alternate_ids"] @links = movie["links"] @directors = movie["abridged_directors"] @studio = movie["studio"] @api = TomatoPower::api Movie.define_movie_methods(*MOVIE_METHOD_ALIAS.keys) end |
Instance Attribute Details
#alternate_ids ⇒ Object (readonly)
Returns the value of attribute alternate_ids.
5 6 7 |
# File 'lib/tomato_power/movie/movie.rb', line 5 def alternate_ids @alternate_ids end |
#critics_consensus ⇒ Object (readonly)
Returns the value of attribute critics_consensus.
5 6 7 |
# File 'lib/tomato_power/movie/movie.rb', line 5 def critics_consensus @critics_consensus end |
#directors ⇒ Object (readonly)
Returns the value of attribute directors.
5 6 7 |
# File 'lib/tomato_power/movie/movie.rb', line 5 def directors @directors end |
#genres ⇒ Object (readonly)
Returns the value of attribute genres.
5 6 7 |
# File 'lib/tomato_power/movie/movie.rb', line 5 def genres @genres end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/tomato_power/movie/movie.rb', line 5 def id @id end |
#info ⇒ Object (readonly)
Returns the value of attribute info.
5 6 7 |
# File 'lib/tomato_power/movie/movie.rb', line 5 def info @info end |
#links ⇒ Object (readonly)
Returns the value of attribute links.
5 6 7 |
# File 'lib/tomato_power/movie/movie.rb', line 5 def links @links end |
#mpaa_rating ⇒ Object (readonly)
Returns the value of attribute mpaa_rating.
5 6 7 |
# File 'lib/tomato_power/movie/movie.rb', line 5 def @mpaa_rating end |
#ratings ⇒ Object (readonly)
Returns the value of attribute ratings.
5 6 7 |
# File 'lib/tomato_power/movie/movie.rb', line 5 def @ratings end |
#release_dates ⇒ Object (readonly)
Returns the value of attribute release_dates.
5 6 7 |
# File 'lib/tomato_power/movie/movie.rb', line 5 def release_dates @release_dates end |
#runtime ⇒ Object (readonly)
Returns the value of attribute runtime.
5 6 7 |
# File 'lib/tomato_power/movie/movie.rb', line 5 def runtime @runtime end |
#studio ⇒ Object (readonly)
Returns the value of attribute studio.
5 6 7 |
# File 'lib/tomato_power/movie/movie.rb', line 5 def studio @studio end |
#synopsis ⇒ Object (readonly)
Returns the value of attribute synopsis.
5 6 7 |
# File 'lib/tomato_power/movie/movie.rb', line 5 def synopsis @synopsis end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
5 6 7 |
# File 'lib/tomato_power/movie/movie.rb', line 5 def title @title end |
#year ⇒ Object (readonly)
Returns the value of attribute year.
5 6 7 |
# File 'lib/tomato_power/movie/movie.rb', line 5 def year @year end |
Class Method Details
.define_movie_methods(*methods) ⇒ Object
TOMATO_METHODS is a hash containing all of the Rotten Tomatoes API calls.
Defines methods that are in MOVIE_METHOD_ALIAS. Straight up delegation is not used because @id needs to be inserted into options before calling the method.
59 60 61 62 63 64 65 66 |
# File 'lib/tomato_power/movie/movie.rb', line 59 def self.define_movie_methods(*methods) methods.each do |method| define_method(method) do |={}| [:movie_id] = @id @api.send(MOVIE_METHOD_ALIAS[method], ) end end end |
Instance Method Details
#cast ⇒ Object
this returns the abridged cast.
cast from a movie
49 50 51 |
# File 'lib/tomato_power/movie/movie.rb', line 49 def cast @actors ||= TomatoPower::Parser::parse_cast @abridged_cast end |
#posters ⇒ Object
Poster for a movie
42 43 44 |
# File 'lib/tomato_power/movie/movie.rb', line 42 def posters @poster_links ||= TomatoPower::Parser::parse_posters @posters end |