Class: IqTriplestorage::BaseAdaptor
- Inherits:
-
Object
- Object
- IqTriplestorage::BaseAdaptor
- Defined in:
- lib/iq_triplestorage.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
Instance Method Summary collapse
- #http_request(method, path, body = nil, headers = {}) ⇒ Object
-
#initialize(host, options = {}) ⇒ BaseAdaptor
constructor
A new instance of BaseAdaptor.
Constructor Details
#initialize(host, options = {}) ⇒ BaseAdaptor
Returns a new instance of BaseAdaptor.
7 8 9 10 11 |
# File 'lib/iq_triplestorage.rb', line 7 def initialize(host, ={}) @host = URI.parse(host).normalize @username = [:username] @password = [:password] end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
5 6 7 |
# File 'lib/iq_triplestorage.rb', line 5 def host @host end |
Instance Method Details
#http_request(method, path, body = nil, headers = {}) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/iq_triplestorage.rb', line 13 def http_request(method, path, body=nil, headers={}) uri = URI.join("#{@host}/", path) req = Net::HTTP.const_get(method.to_s.downcase.capitalize).new(uri.to_s) req.basic_auth(@username, @password) if (@username && @password) headers.each { |key, value| req[key] = value } req.body = body if body return Net::HTTP.new(uri.host, uri.port).request(req) end |