Module: Pixmatch::Client::Search
- Included in:
- Pixmatch::Client
- Defined in:
- lib/pixmatch/client/search.rb
Instance Method Summary collapse
-
#search(image, options = {}) ⇒ Object
Given an image, search against our collection and return any matches with corresponding scores.
Instance Method Details
#search(image, options = {}) ⇒ Object
Given an image, search against our collection and return any matches with corresponding scores.
11 12 13 14 15 16 17 18 |
# File 'lib/pixmatch/client/search.rb', line 11 def search(image, = {}) payload = { "image" => image.is_a?(File) ? image : File.new(image, "rb") } response = request(:post, 'rest', { method: 'search' }.merge(), { payload: payload }) result = response['result'] raise "Missing result in response." if result.nil? raise "Invalid result in response (#{result.class.name})." if ! result.is_a?(Array) result end |