Class: AurJson::Query
- Inherits:
-
Object
- Object
- AurJson::Query
- Defined in:
- lib/aur_json.rb
Instance Attribute Summary collapse
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Instance Method Summary collapse
-
#initialize(type, arg) ⇒ Query
constructor
A new instance of Query.
Constructor Details
#initialize(type, arg) ⇒ Query
Returns a new instance of Query.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# 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 |
Instance Attribute Details
#result ⇒ Object (readonly)
Returns the value of attribute result.
12 13 14 |
# File 'lib/aur_json.rb', line 12 def result @result end |