Class: Nytimes::Events::Base
- Inherits:
-
Object
- Object
- Nytimes::Events::Base
- Defined in:
- lib/nytimes-events/base.rb
Direct Known Subclasses
Constant Summary collapse
- API_SERVER =
'api.nytimes.com'
- API_VERSION =
'v2'
- API_NAME =
'events'
- API_OBJECTS =
'listings'
- RESPONSE_TYPE =
'json'
- API_URL =
"http://#{API_SERVER}/svc/#{API_NAME}/#{API_VERSION}/listings.#{RESPONSE_TYPE}"
Instance Method Summary collapse
- #api_key ⇒ Object
- #api_key=(key) ⇒ Object
- #api_url(params) ⇒ Object
-
#initialize(api_key) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(api_key) ⇒ Base
Returns a new instance of Base.
11 12 13 |
# File 'lib/nytimes-events/base.rb', line 11 def initialize(api_key) @api_key = api_key end |
Instance Method Details
#api_key ⇒ Object
19 20 21 |
# File 'lib/nytimes-events/base.rb', line 19 def api_key @api_key end |
#api_key=(key) ⇒ Object
15 16 17 |
# File 'lib/nytimes-events/base.rb', line 15 def api_key=(key) @api_key = key end |
#api_url(params) ⇒ Object
23 24 25 26 |
# File 'lib/nytimes-events/base.rb', line 23 def api_url(params) prmstr = params.collect { |k, v| "#{k.to_s}=#{v.to_s.gsub(' ','+')}" }.join('&') + "&api-key=" + api_key API_URL + "?" + prmstr end |