Class: WorldBank::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/world_bank/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#queryObject

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_queryObject



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