class FilmBuff::Title

Represents a single title from IMDb and contains all available data on it

Attributes

genres[R]

@return [Array<String>] The genres of Title

imdb_id[R]

@return [String] The IMDb ID of Title

plot[R]

@return [String] The plot summary of Title

poster_url[R]

@return [String] The URL for the poster of Title

rating[R]

@return [Float] The IMDb rating of Title

release_date[R]

@return [Date, String] The release date of Title. Returns a Date when

possible, otherwise a String
runtime[R]

@return [Integer] The runtime of Title in seconds

tagline[R]

@return [String] The tagline of Title

title[R]

@return [String] The title of Title

votes[R]

@return [Integer] The amount of votes that have been used to determine

the rating of Title

Public Class Methods

new(imdb_hash) click to toggle source

Create a new Title instance from an IMDb hash

@param [Hash] imdb_hash

The hash with IMDb information to create a Title instance from
# 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