Sha256: 2ba0c55d7b0083b0915b37a69b362f4b82d4042bda45c5c2e2baa9104d2c8d75
Contents?: true
Size: 954 Bytes
Versions: 1
Compression:
Stored size: 954 Bytes
Contents
require 'calil/library' require 'calil/check' require 'open-uri' require 'json' module Calil class API attr_reader :app_key ROOT_URL = 'http://api.calil.jp/' # API.new(app_key: 'Your app_key') def initialize(app_key:) @app_key = app_key end # Use library database def library_search(options={}) query = '' options.each do |key, value| query += "&#{key}=#{value}" end url = "#{ROOT_URL}library?app_key=#{@app_key+query}&format=json&callback=" post_library_url(url) end def check_search(options={}) query = '' options.each do |key, value| query += "&#{key}=#{value}" end url = "#{ROOT_URL}check?app_key=#{@app_key+query}&format=json&callback=no" Check.new(open(url) {|f| JSON.load(f)}) end def post_library_url(url) json = open(url) {|f| JSON.load(f)} json.map {|hash| Library.new( hash ) } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
calilen-0.1.1 | lib/calil/api.rb |