class Rubyrubi::API

Constants

API_PATH
BASE_URL

Public Class Methods

request(app_id, text) click to toggle source
# File lib/rubyrubi/api.rb, line 12
def request(app_id, text)
  uri = URI(BASE_URL + API_PATH)
  uri.query = {
    appid: app_id,
    filter: [*1..13].join('|'),
    results: 'ma',
    ma_response: 'surface,reading,pos,feature',
    sentence: text,
  }.to_param
  #p uri

  load_xml(uri)
end

Private Class Methods

load_xml(uri) click to toggle source
# File lib/rubyrubi/api.rb, line 28
def load_xml(uri)
  http = Net::HTTP.new(uri.host, uri.port)
  responce = http.post(uri.path, uri.query, {
    'Content-type' => 'application/x-www-form-urlencoded'
  })

  Hash.from_xml(responce.body)
end