Class: Rotten::Movie

Inherits:
Entity
  • Object
show all
Includes:
Api
Defined in:
lib/rotten/movie.rb

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.



52
53
54
55
56
# File 'lib/rotten/movie.rb', line 52

def initialize movie_hash={}
  super
  @actors = []
  process movie_hash
end

Instance Attribute Details

#actorsObject (readonly)

Returns the value of attribute actors.



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

def actors
  @actors
end

#cast(kind = :abridged) ⇒ Rotten::Cast (readonly)

Show cast

Parameters:

  • Defaults (Symbol #kind)

    to :abridged, but can accept :full to retrieve full cast info.

Returns:



79
80
81
# File 'lib/rotten/movie.rb', line 79

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

.find_first(phrase, options = {}) ⇒ Object



31
32
33
# File 'lib/rotten/movie.rb', line 31

def find_first phrase, options={}
  (search phrase, options.merge(:page_limit => 1))[0]
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

#inspectObject



58
59
60
# File 'lib/rotten/movie.rb', line 58

def inspect 
  "<Rotten::Movie title='#{title}' id='#{id}'>"
end

#process(hash) ⇒ Object



90
91
92
93
94
# File 'lib/rotten/movie.rb', line 90

def process hash
  attributes= hash
  @cast       = Cast.new( abridged_cast )
  @actors     = @cast.actors
end

#reloadRotten::Movie

Fetch updated, potentially additional movie information

Returns:



98
99
100
101
102
103
104
# File 'lib/rotten/movie.rb', line 98

def reload
  return false unless id
  Movie.get "movies/#{id}" do |json|
    process json 
  end
  self
end

#reviews(options = {}) ⇒ Array

Moview reviews

Returns:

  • (Array)


68
69
70
71
72
73
# File 'lib/rotten/movie.rb', line 68

def reviews options={}
  path = "movies/#{id}/reviews"
  Movie.get path, options.merge(:page_limit => Movie.maximum_per_page) do |json|
    SearchResult.new( :path => path, :api_options => options, :class => Review, :json => json, :start => "reviews" )
  end
end

#to_sObject



62
63
64
# File 'lib/rotten/movie.rb', line 62

def to_s
  title
end