Class: Tmdb::Movie
Instance Attribute Summary
Attributes inherited from TmdbBase
#id, #info
Instance Method Summary
collapse
Methods inherited from TmdbBase
#api, #changes, #status_message
Constructor Details
#initialize(id) ⇒ Movie
Returns a new instance of Movie.
4
5
6
7
|
# File 'lib/tmdb/movie.rb', line 4
def initialize(id)
@id = id
@info = api.movie(id)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
45
46
47
48
49
50
51
|
# File 'lib/tmdb/movie.rb', line 45
def method_missing(method, *args, &block)
if @info.respond_to?(method)
@info.send(method, *args, &block)
else
super
end
end
|
Instance Method Details
#backdrops ⇒ Object
21
22
23
24
25
26
27
|
# File 'lib/tmdb/movie.rb', line 21
def backdrops
_images = images.backdrops.map{|p| OpenStruct.new(p)}
unless _images.map{|i| i.file_path}.include?(backdrop_path)
_images << OpenStruct.new({file_path: backdrop_path})
end
return _images
end
|
#cast ⇒ Object
29
30
31
|
# File 'lib/tmdb/movie.rb', line 29
def cast
api.movie_credits(id).cast.map{|c| OpenStruct.new(c)}
end
|
#crew ⇒ Object
33
34
35
|
# File 'lib/tmdb/movie.rb', line 33
def crew
api.movie_credits(id).crew.map{|c| OpenStruct.new(c)}
end
|
#images ⇒ Object
9
10
11
|
# File 'lib/tmdb/movie.rb', line 9
def images
api.movie_images(id)
end
|
#posters ⇒ Object
13
14
15
16
17
18
19
|
# File 'lib/tmdb/movie.rb', line 13
def posters
_images = images.posters.map{|p| OpenStruct.new(p)}
unless _images.map{|i| i.file_path}.include?(poster_path)
_images << OpenStruct.new({file_path: poster_path})
end
return _images
end
|
#release_date ⇒ Object
41
42
43
|
# File 'lib/tmdb/movie.rb', line 41
def release_date
Date.parse(@info.release_date) rescue nil
end
|
#videos ⇒ Object
37
38
39
|
# File 'lib/tmdb/movie.rb', line 37
def videos
api.movie_videos(id).results.map{|t| OpenStruct.new(t)}
end
|