Class: Rubyidescat::Client
- Inherits:
-
Object
- Object
- Rubyidescat::Client
- Defined in:
- lib/rubyidescat/client.rb
Constant Summary collapse
- BASE_URL =
'http://api.idescat.cat/'
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ Client
constructor
A new instance of Client.
- #poblacio(version, format, operation, params = {}) ⇒ Object
- #request_url ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ Client
Returns a new instance of Client.
9 10 11 12 13 |
# File 'lib/rubyidescat/client.rb', line 9 def initialize(attributes = {}) attributes.each do |attr, value| self.send("#{attr}=", value) end end |
Instance Method Details
#poblacio(version, format, operation, params = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/rubyidescat/client.rb', line 15 def poblacio(version, format, operation, params = {}) @format = format @version = version @operation = operation @params = params @request_url = BASE_URL + 'pob/' + @version + '/' + @operation + '.' + @format @request_url += '?p=' + @params.map{|k,v|"#{k}/#{[v].flatten.join(",")}"}.join(";") unless @params.empty? make_call end |
#request_url ⇒ Object
5 6 7 |
# File 'lib/rubyidescat/client.rb', line 5 def request_url URI.escape(@request_url) end |