Class: Rotten::Movie
Defined Under Namespace
Classes: InvalidSearchQueryError
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Api
included
Methods inherited from Entity
#attributes=, from_json
Constructor Details
#initialize(movie_hash = {}) ⇒ Movie
Returns a new instance of Movie.
48
49
50
51
52
|
# File 'lib/rotten/movie.rb', line 48
def initialize movie_hash={}
super
@actors = []
process movie_hash
end
|
Instance Attribute Details
#actors ⇒ Object
Returns the value of attribute actors.
47
48
49
|
# File 'lib/rotten/movie.rb', line 47
def actors
@actors
end
|
#cast(kind = :abridged) ⇒ Rotten::Cast
74
75
76
|
# File 'lib/rotten/movie.rb', line 74
def cast
@cast
end
|
Class Method Details
.dvd_releases(options = {}) ⇒ Object
15
16
17
|
# File 'lib/rotten/movie.rb', line 15
def dvd_releases options={}
fetch "lists/dvds/new_releases", options
end
|
31
32
33
34
35
36
37
|
# File 'lib/rotten/movie.rb', line 31
def json={}
if json.is_a?(Array)
json.map{|m| (m) }
else
Movie.new(json)
end
end
|
.in_theaters(options = {}) ⇒ Object
Also known as:
in_theatres
19
20
21
|
# File 'lib/rotten/movie.rb', line 19
def in_theaters options={}
fetch "lists/movies/in_theaters", options
end
|
.opening(options = {}) ⇒ Object
7
8
9
|
# File 'lib/rotten/movie.rb', line 7
def opening options={}
fetch "lists/movies/opening", options
end
|
.search(phrase, options = {}) ⇒ Object
24
25
26
27
28
29
|
# File 'lib/rotten/movie.rb', line 24
def search phrase, options={}
options.delete :q
options[:q] = phrase
fetch "movies/search", options
end
|
.upcoming(options = {}) ⇒ Object
11
12
13
|
# File 'lib/rotten/movie.rb', line 11
def upcoming options={}
fetch "lists/movies/upcoming", options
end
|
Instance Method Details
#inspect ⇒ Object
54
55
56
|
# File 'lib/rotten/movie.rb', line 54
def inspect
"<Rotten::Movie title='#{title}' id='#{id}'>"
end
|
#process(hash) ⇒ Object
85
86
87
88
89
|
# File 'lib/rotten/movie.rb', line 85
def process hash
attributes= hash
@cast = Cast.new( abridged_cast )
@actors = @cast.actors
end
|
Fetch updated, potentially additional movie information
93
94
95
96
97
98
99
|
# File 'lib/rotten/movie.rb', line 93
def reload
return false unless id
Movie.get "movies/#{id}" do |json|
process json
end
self
end
|
#reviews(options = {}) ⇒ Array
64
65
66
67
68
|
# File 'lib/rotten/movie.rb', line 64
def reviews options={}
Movie.get "movies/#{id}/reviews", options do |json|
json["reviews"].map{|review| Review.from_json(review) }
end
end
|
#to_s ⇒ Object
58
59
60
|
# File 'lib/rotten/movie.rb', line 58
def to_s
title
end
|