class Rubyidescat::Client

Constants

BASE_URL

Public Class Methods

new(attributes = {}) click to toggle source
# File lib/rubyidescat/client.rb, line 9
def initialize(attributes = {})
  attributes.each do |attr, value|
    self.send("#{attr}=", value)
  end
end

Public Instance Methods

poblacio(version, format, operation, params = {}) click to toggle source
# 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() click to toggle source
# File lib/rubyidescat/client.rb, line 5
def request_url
  URI.escape(@request_url)
end

Private Instance Methods

make_call() click to toggle source
# File lib/rubyidescat/client.rb, line 27
def make_call
  response = HTTParty.get self.request_url
  return JSON.parse response.body
end