Method: Narou::API#request_api
- Defined in:
- lib/narou/api.rb
#request_api(ncodes, limit = BATCH_LIMIT) ⇒ Object
56 57 58 59 60 61 62 63 64 |
# File 'lib/narou/api.rb', line 56 def request_api(ncodes, limit = BATCH_LIMIT) url = "#{@api_url}?gzip=#{GZIP_LEVEL}&ncode=#{ncodes.join("-")}&of=#{@of}&lim=#{limit}&out=json" open(url) do |fp| data = Zlib::GzipReader.wrap(fp).read.force_encoding(Encoding::UTF_8) results = JSON.parse(data) return if results[0]["allcount"].zero? store_results(results.drop(1)) end end |