Class: TMDBParty::Movie

Inherits:
Object
  • Object
show all
Includes:
Attributes
Defined in:
lib/tmdb_party/movie.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Attributes

included

Constructor Details

#initialize(values, tmdb) ⇒ Movie

Returns a new instance of Movie.



22
23
24
25
# File 'lib/tmdb_party/movie.rb', line 22

def initialize(values, tmdb)
  @tmdb = tmdb
  self.attributes = values
end

Instance Attribute Details

#tmdbObject (readonly)

Returns the value of attribute tmdb.



4
5
6
# File 'lib/tmdb_party/movie.rb', line 4

def tmdb
  @tmdb
end

Instance Method Details

#actorsObject



51
52
53
# File 'lib/tmdb_party/movie.rb', line 51

def actors
  find_cast('Actors')
end

#castObject



33
34
35
36
# File 'lib/tmdb_party/movie.rb', line 33

def cast
  # TODO: This needs refactoring
  CastMember.parse(read_or_load_attribute('cast', nil, :get_info!), tmdb)
end

#directorsObject



47
48
49
# File 'lib/tmdb_party/movie.rb', line 47

def directors
  find_cast('Directing')
end

#get_info!Object



27
28
29
30
31
# File 'lib/tmdb_party/movie.rb', line 27

def get_info!
  movie = tmdb.get_info(self.id)
  @attributes.merge!(movie.attributes) if movie
  @loaded = true
end

#languageObject



38
39
40
# File 'lib/tmdb_party/movie.rb', line 38

def language
  read_attribute('language').downcase.to_sym
end

#last_modified_atObject



42
43
44
45
# File 'lib/tmdb_party/movie.rb', line 42

def last_modified_at
  # Date from TMDB is always in MST, but no timezone is present in date string
  Time.parse(read_attribute('last_modified_at') + ' MST')
end

#producersObject



59
60
61
# File 'lib/tmdb_party/movie.rb', line 59

def producers
  find_cast('Production')
end

#writersObject



55
56
57
# File 'lib/tmdb_party/movie.rb', line 55

def writers
  find_cast('Writing')
end