Class: Nobel::Api
- Inherits:
-
Object
- Object
- Nobel::Api
- Defined in:
- lib/nobel/api.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
Instance Method Summary collapse
- #country ⇒ Object
- #get(path, params = {}) ⇒ Object
- #get_json(endpoint, params = {}) ⇒ Object
-
#initialize(config) ⇒ Api
constructor
A new instance of Api.
- #laureate(params = {}) ⇒ Object
- #prize(params = {}) ⇒ Object
Constructor Details
#initialize(config) ⇒ Api
Returns a new instance of Api.
10 11 12 |
# File 'lib/nobel/api.rb', line 10 def initialize(config) @config = config end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
8 9 10 |
# File 'lib/nobel/api.rb', line 8 def config @config end |
Instance Method Details
#country ⇒ Object
22 23 24 |
# File 'lib/nobel/api.rb', line 22 def country get_json :country end |
#get(path, params = {}) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/nobel/api.rb', line 30 def get(path, params = {}) uri = prepared_uri(path, params) puts "GET: #{uri}" if @config.debug? http_get(uri) end |
#get_json(endpoint, params = {}) ⇒ Object
26 27 28 |
# File 'lib/nobel/api.rb', line 26 def get_json(endpoint, params = {}) load_json get("#{endpoint}.json", params) || "{}" end |
#laureate(params = {}) ⇒ Object
18 19 20 |
# File 'lib/nobel/api.rb', line 18 def laureate(params = {}) get_json :laureate, params end |
#prize(params = {}) ⇒ Object
14 15 16 |
# File 'lib/nobel/api.rb', line 14 def prize(params = {}) get_json :prize, params end |