class AurJson::Query

Attributes

result[R]

Public Class Methods

new(type, arg) click to toggle source
# File lib/aur_json.rb, line 14
def initialize type, arg
  unless %w(search msearch info multiinfo).include? type
    raise "ERROR: Unknown query type #{type}"
  end

  # The rpc.php script on the server will handle other errors
  base = "https://aur.archlinux.org/rpc.php?type="
  uri = URI("#{base}#{type}&arg=#{arg}")

  Net::HTTP.start(uri.host, uri.port,
    :use_ssl => uri.scheme == 'https') do |http|
    request = Net::HTTP::Get.new uri
    response = http.request request
    @result = JSON.parse response.body
  end
end