Class: WorldBank::Client
- Inherits:
-
Object
- Object
- WorldBank::Client
- Defined in:
- lib/world_bank/client.rb
Instance Attribute Summary collapse
-
#query ⇒ Object
Returns the value of attribute query.
Instance Method Summary collapse
- #get(path, headers = {}) ⇒ Object
- #get_query ⇒ Object
-
#initialize(query, raw) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(query, raw) ⇒ Client
Returns a new instance of Client.
19 20 21 22 |
# File 'lib/world_bank/client.rb', line 19 def initialize(query, raw) @query = query @raw = raw end |
Instance Attribute Details
#query ⇒ Object
Returns the value of attribute query.
17 18 19 |
# File 'lib/world_bank/client.rb', line 17 def query @query end |
Instance Method Details
#get(path, headers = {}) ⇒ Object
35 36 37 38 39 40 |
# File 'lib/world_bank/client.rb', line 35 def get(path, headers={}) response = connection.get do |request| request.url(path, headers) end response.body end |
#get_query ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/world_bank/client.rb', line 24 def get_query @path = @query[:dirs].join('/') @path += '?' params = [] @query[:params].each do |key, value| params << "#{key.to_s}=#{value.to_s}" end @path += params.join('&') get(@path) end |