Class: RottenTomatoes::RottenMovie

Inherits:
Object
  • Object
show all
Defined in:
lib/rottentomatoes/rotten_movie.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.find(options) ⇒ Object

Raises:

  • (ArgumentError)


5
6
7
8
9
10
11
12
# File 'lib/rottentomatoes/rotten_movie.rb', line 5

def self.find(options)
  raise ArgumentError, "You must search by title or id" if (options[:title].nil? && options[:id].nil?)

  results = []
  results << Rotten.api_call("movies", options)

  return Rotten.process_results(results, options)
end

.new(raw_data, expand_results = false) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/rottentomatoes/rotten_movie.rb', line 14

def self.new(raw_data, expand_results = false)
  if (expand_results && !has_expanded_data?(raw_data))
    raw_data = Rotten.api_call("movies", :id => raw_data["id"])
    if !raw_data["links"].nil?
      reviews = Rotten.api_call("direct", raw_data["links"]["reviews"]) if (!raw_data["links"]["reviews"].nil?)
      cast = Rotten.api_call("direct", raw_data["links"]["cast"]) if (!raw_data["links"]["cast"].nil?)

      raw_data = raw_data.merge(reviews) if (!reviews.nil?)
      raw_data = raw_data.merge(cast) if (!cast.nil?)
    end
  end
  return Rotten.data_to_object(raw_data)
end

Instance Method Details

#==(other) ⇒ Object



28
29
30
31
# File 'lib/rottentomatoes/rotten_movie.rb', line 28

def ==(other)
  return false unless (other.is_a?(RottenMovie))
  return @raw_data == other.raw_data
end