Class: TomatoPower::API
- Inherits:
-
Object
- Object
- TomatoPower::API
- Defined in:
- lib/tomato_power/api/api.rb
Overview
API class to interface with Client
Class Method Summary collapse
-
.define_tomato_methods(*methods) ⇒ Object
Defines methods that are in TOMATO_METHODS.
Instance Method Summary collapse
-
#initialize(api_key) ⇒ API
constructor
A new instance of API.
Constructor Details
#initialize(api_key) ⇒ API
Returns a new instance of API.
8 9 10 11 |
# File 'lib/tomato_power/api/api.rb', line 8 def initialize api_key @api_key = api_key API.define_tomato_methods(*TOMATO_METHODS.keys) end |
Class Method Details
.define_tomato_methods(*methods) ⇒ Object
Note:
TOMATO_METHODS is a hash containing all of the Rotten Tomatoes API calls.
Defines methods that are in TOMATO_METHODS
18 19 20 21 22 23 24 |
# File 'lib/tomato_power/api/api.rb', line 18 def self.define_tomato_methods(*methods) methods.each do |method| define_method(method) do |={}| fetch(TOMATO_METHODS[method][:url], @api_key, ) if method, end end end |