Class: Fredric::API
- Inherits:
-
APICake::Base
- Object
- APICake::Base
- Fredric::API
- Defined in:
- lib/fredric/api.rb
Overview
Provides access to all the FRED API endpoints with dynamic methods anc caching.
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
Instance Method Summary collapse
- #default_query ⇒ Object
-
#initialize(api_key, opts = {}) ⇒ API
constructor
A new instance of API.
Constructor Details
#initialize(api_key, opts = {}) ⇒ API
Returns a new instance of API.
11 12 13 14 15 16 |
# File 'lib/fredric/api.rb', line 11 def initialize(api_key, opts={}) @api_key = api_key cache.disable unless opts[:use_cache] cache.dir = opts[:cache_dir] if opts[:cache_dir] cache.life = opts[:cache_life] if opts[:cache_life] end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
9 10 11 |
# File 'lib/fredric/api.rb', line 9 def api_key @api_key end |
Instance Method Details
#default_query ⇒ Object
18 19 20 |
# File 'lib/fredric/api.rb', line 18 def default_query { api_key: api_key, file_type: :json } end |