Class: FilmBuff::Title
- Inherits:
-
Object
- Object
- FilmBuff::Title
- Defined in:
- lib/filmbuff/title.rb
Overview
Represents a single title from IMDb and contains all available data on it
Instance Attribute Summary collapse
-
#genres ⇒ Array<String>
readonly
The genres of Title.
-
#imdb_id ⇒ String
readonly
The IMDb ID of Title.
-
#plot ⇒ String
readonly
The plot summary of Title.
-
#poster_url ⇒ String
readonly
The URL for the poster of Title.
-
#rating ⇒ Float
readonly
The IMDb rating of Title.
-
#release_date ⇒ Date, String
readonly
The release date of Title.
-
#runtime ⇒ Integer
readonly
The runtime of Title in seconds.
-
#tagline ⇒ String
readonly
The tagline of Title.
-
#title ⇒ String
readonly
The title of Title.
-
#votes ⇒ Integer
readonly
The amount of votes that have been used to determine the rating of Title.
Instance Method Summary collapse
-
#initialize(imdb_hash) ⇒ Title
constructor
Create a new Title instance from an IMDb hash.
Constructor Details
#initialize(imdb_hash) ⇒ Title
Create a new Title instance from an IMDb hash
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/filmbuff/title.rb', line 42 def initialize(imdb_hash) @imdb_id = imdb_hash['tconst'] @title = imdb_hash['title'] @tagline = imdb_hash['tagline'] if imdb_hash['tagline'] @plot = imdb_hash['plot']['outline'] if imdb_hash['plot'] @runtime = imdb_hash['runtime']['time'] if imdb_hash['runtime'] @rating = imdb_hash['rating'] @votes = imdb_hash['num_votes'] @poster_url = imdb_hash['image']['url'] if imdb_hash['image'] @genres = imdb_hash['genres'] || [] if imdb_hash['release_date'] begin @release_date = Date.strptime(imdb_hash['release_date']['normal'], '%Y-%m-%d') rescue @release_date = imdb_hash['release_date']['normal'] end end end |
Instance Attribute Details
#genres ⇒ Array<String> (readonly)
Returns The genres of Title.
32 33 34 |
# File 'lib/filmbuff/title.rb', line 32 def genres @genres end |
#imdb_id ⇒ String (readonly)
Returns The IMDb ID of Title.
7 8 9 |
# File 'lib/filmbuff/title.rb', line 7 def imdb_id @imdb_id end |
#plot ⇒ String (readonly)
Returns The plot summary of Title.
16 17 18 |
# File 'lib/filmbuff/title.rb', line 16 def plot @plot end |
#poster_url ⇒ String (readonly)
Returns The URL for the poster of Title.
29 30 31 |
# File 'lib/filmbuff/title.rb', line 29 def poster_url @poster_url end |
#rating ⇒ Float (readonly)
Returns The IMDb rating of Title.
22 23 24 |
# File 'lib/filmbuff/title.rb', line 22 def @rating end |
#release_date ⇒ Date, String (readonly)
Returns The release date of Title. Returns a Date when possible, otherwise a String.
36 37 38 |
# File 'lib/filmbuff/title.rb', line 36 def release_date @release_date end |
#runtime ⇒ Integer (readonly)
Returns The runtime of Title in seconds.
19 20 21 |
# File 'lib/filmbuff/title.rb', line 19 def runtime @runtime end |
#tagline ⇒ String (readonly)
Returns The tagline of Title.
13 14 15 |
# File 'lib/filmbuff/title.rb', line 13 def tagline @tagline end |
#title ⇒ String (readonly)
Returns The title of Title.
10 11 12 |
# File 'lib/filmbuff/title.rb', line 10 def title @title end |
#votes ⇒ Integer (readonly)
Returns The amount of votes that have been used to determine the rating of Title.
26 27 28 |
# File 'lib/filmbuff/title.rb', line 26 def votes @votes end |