Class: Fredric::API

Inherits:
APICake::Base
  • Object
show all
Defined in:
lib/fredric/api.rb

Overview

Provides access to all the FRED API endpoints with dynamic methods anc caching.

Instance Attribute Summary collapse

Instance Method Summary collapse

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_keyObject (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_queryObject



18
19
20
# File 'lib/fredric/api.rb', line 18

def default_query
  { api_key: api_key, file_type: :json } 
end