Sha256: 6b87682eefe9a0fce2aa94db9f46f7191fa7e60ba3f1cb50772b7ed127c8e08c

Contents?: true

Size: 609 Bytes

Versions: 2

Compression:

Stored size: 609 Bytes

Contents

module YaCan::YahooAPI

  @@host = 'jlp.yahooapis.jp'
  @@appid = nil

  def appid
    return @@appid || (raise AppIDUnconfiguredError)
  end

  def appid=(appid)
    @@appid = appid
  end

  def request(path, params={})
    params['appid'] = appid
    Net::HTTP::Proxy(YaCan.proxy_host, YaCan.proxy_port).start(@@host){ |http|
      res = http.post(path, params.map{ |k,v| "#{URI.encode(k)}=#{URI.encode(v)}"}.join('&'))
      res.body
    }
  end

  def analyze(*args)
    raise NotImplementedError
  end

  module_function :appid, :appid=, :request

  class AppIDUnconfiguredError < StandardError; end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
yacan-0.1.1 lib/yacan/yahoo_api.rb
yacan-0.1.0 lib/yacan/yahoo_api.rb