Class: RottenTomatoes::RottenList

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

Class Method Summary collapse

Class Method Details

.find(options) ⇒ Object

Raises:

  • (ArgumentError)


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/rottentomatoes/rotten_list.rb', line 5

def self.find(options)
  raise ArgumentError, ":type must be set" if (options[:type].nil?)

  if !["box_office", "in_theaters", "opening", "upcoming", "new_releases",
       "top_rentals", "current_releases"].include?(options[:type])
    raise ArgumentError, ":type must be a recognized format, found #{options[:type].inspect}"
  end

  section = options[:section]
  unless section.nil? || ['movies', 'dvds'].include?(section)
    raise ArgumentError,
      ":section must be either 'movies' (default) or 'dvds', found #{section.inspect}"
  end

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

  return Rotten.process_results(results, options)
end