Sha256: e38403dcfaac18f25aee8ecf2f89ffb8426d0b4c2cbdfa76bfaf95e0833d0a6a
Contents?: true
Size: 782 Bytes
Versions: 1
Compression:
Stored size: 782 Bytes
Contents
module Rubyidescat class Client BASE_URL = 'http://api.idescat.cat/' def request_url URI.escape(@request_url) end def initialize(attributes = {}) attributes.each do |attr, value| self.send("#{attr}=", value) end end 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 private def make_call response = HTTParty.get self.request_url return JSON.parse response.body end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rubyidescat-0.0.1 | lib/rubyidescat/client.rb |