Class: MovieAPI
- Inherits:
-
Object
- Object
- MovieAPI
- Defined in:
- lib/mmapi.rb
Constant Summary collapse
- API_URL =
'http://mymovieapi.com/'
Class Method Summary collapse
- .search_by_id(options = {}) ⇒ Object
-
.search_by_title(title, options = {}) ⇒ Array
Queries the API for a movie title.
Class Method Details
.search_by_id(options = {}) ⇒ Object
9 10 11 |
# File 'lib/mmapi.rb', line 9 def self.search_by_id( = {}) end |
.search_by_title(title, options = {}) ⇒ Array
Queries the API for a movie title
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/mmapi.rb', line 32 def self.search_by_title(title, = {}) params = ? .collect {|key, value| "#{key}=#{URI::encode(value)}"}.join('&') : '' uri = "http://mymovieapi.com?q=#{URI::encode(title)}" + params p uri response = open("http://mymovieapi.com?q=#{URI::encode(title)}&" + params).read data = JSON.parse(response) return data end |