Class: Onyx::Client
- Inherits:
-
Object
- Object
- Onyx::Client
- Defined in:
- lib/onyx_client/client.rb
Class Method Summary collapse
Class Method Details
.delete(key) ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/onyx_client/client.rb', line 31 def delete(key) settings = Onyx::Configuration.settings response = Net::HTTP.start(settings[:host], settings[:port]) do |http| request = Net::HTTP::Delete.new(settings[:path]) params = { key: key } request.body = params.to_json http.request(request) end JSON.parse(response.body, :symbolize_names => true) end |
.index(key, string_file) ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/onyx_client/client.rb', line 9 def index(key, string_file) settings = Onyx::Configuration.settings response = Net::HTTP.start(settings[:host], settings[:port]) do |http| request = Net::HTTP::Put.new(settings[:path]) params = { key: key, image: string_file } request.body = params.to_json http.request(request) end JSON.parse(response.body, :symbolize_names => true) end |
.search(string_file) ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/onyx_client/client.rb', line 20 def search(string_file) settings = Onyx::Configuration.settings response = Net::HTTP.start(settings[:host], settings[:port]) do |http| request = Net::HTTP::Post.new(settings[:path]) params = { image: string_file } request.body = params.to_json http.request(request) end JSON.parse(response.body, :symbolize_names => true) end |