Class: AurJson::Query
- Inherits:
-
Object
- Object
- AurJson::Query
- Defined in:
- lib/aur_json.rb
Instance Method Summary collapse
-
#initialize(type, arg) ⇒ Query
constructor
Return a hash with results value of an array of hashes of results.
Constructor Details
#initialize(type, arg) ⇒ Query
Return a hash with results value of an array of hashes of results
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/aur_json.rb', line 13 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 |