Sha256: f45bee69c85ed9f06bd6aaa98a775f3207a57c0866bde5e34fce001d3ea2a41d

Contents?: true

Size: 970 Bytes

Versions: 3

Compression:

Stored size: 970 Bytes

Contents

class TmdbInfo

  def initialize(profile)
    @profile = profile
  end

  # == Synopsis
  # load data from themovieDb.com
  # see TmdbProfile.all for options
  def self.find(options)
    tmdb_info = nil
    profile = TmdbProfile.first(options)
    unless profile.nil?
      tmdb_info = TmdbInfo.new(profile)
    end
    tmdb_info
  end

  private

  # == Synopsis
  # map the tmdb.movie hash into the info hash
  TMDB_HASH_TO_INFO_MAP = {
      # urls
      # scores
      # idents
      # titles
      # imdb_ids
      # alternative_titles
      # posters
      # types
      # fanarts
      'short_overviews' => 'plot',
      'releases' => 'year'
    }

  public

  # == Synopsis
  # map the tmdb.movie hash into the info hash
  def to_xbmc_info
    info = Hash.new
    unless @profile.movie.blank?
      TMDB_HASH_TO_INFO_MAP.each do |key, value|
        info[value] = @profile.movie[key].first unless @profile.movie[key].blank?
      end
    end
    info
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
royw-dvdprofiler2xbmc-0.0.19 lib/dvdprofiler2xbmc/models/tmdb_info.rb
royw-dvdprofiler2xbmc-0.1.0 lib/dvdprofiler2xbmc/models/tmdb_info.rb
royw-dvdprofiler2xbmc-0.1.2 lib/dvdprofiler2xbmc/models/tmdb_info.rb