Sha256: 0b880a6f99bf5c3bba4b4a938c800e308db39e6c87b1e407712756b112dfb68b
Contents?: true
Size: 1.54 KB
Versions: 1
Compression:
Stored size: 1.54 KB
Contents
require ::File.expand_path('../client/connection', __FILE__) require ::File.expand_path('../client/request', __FILE__) require ::File.expand_path('../client/data.rb', __FILE__) require ::File.expand_path('../client/loans.rb', __FILE__) require ::File.expand_path('../client/licenses.rb', __FILE__) require ::File.expand_path('../client/sites.rb', __FILE__) require ::File.expand_path('../client/urls.rb', __FILE__) module SBA class Client attr_accessor *Configuration::VALID_OPTIONS_KEYS def initialize(options={}) options = SBA.options.merge(options) Configuration::VALID_OPTIONS_KEYS.each do |key| send("#{key}=", options[key]) end end include SBA::Client::Connection include SBA::Client::Request include SBA::Client::Data include SBA::Client::Urls include SBA::Client::Loans include SBA::Client::Licenses include SBA::Client::Sites private #some JSON replies we get back are in an ugly format. simplify them def simplify_response(response) #the returned 'key' is pretty useless. the key=>value thing here is basically an array #within that, we're given an array of key=>value pairs. we want this to be one big hash. Hash[*response.group_by {|key,val| key.match(/(.*)_item/)[1]}.map do |section,items| [section, items.inject([]) do |array,(key,value)| i = key.match(/\d+$/)[0].to_i array[i] = value.inject({}) {|all,current| all.merge! current} array end] end.flatten(1)] end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sba-0.0.1 | lib/sba/client.rb |