class Clarifai::Rails::Image
Attributes
json[R]
Public Class Methods
new(json)
click to toggle source
# File lib/clarifai/rails/image.rb, line 5 def initialize(json) @json = json.symbolize_keys end
Public Instance Methods
concepts()
click to toggle source
# File lib/clarifai/rails/image.rb, line 19 def concepts raise error if error? data[:concepts].map{ |item| item['name'] } end
concepts_with_percent()
click to toggle source
# File lib/clarifai/rails/image.rb, line 24 def concepts_with_percent data[:concepts].map do |item| [item['name'], item['value']] end.to_h end
docid()
click to toggle source
# File lib/clarifai/rails/image.rb, line 9 def docid json[:id] end
error()
click to toggle source
# File lib/clarifai/rails/image.rb, line 38 def error Clarifai::Rails::Error.detector(status_code) end
error?()
click to toggle source
# File lib/clarifai/rails/image.rb, line 42 def error? error.present? end
status_code()
click to toggle source
# File lib/clarifai/rails/image.rb, line 30 def status_code status[:code] end
status_messages()
click to toggle source
# File lib/clarifai/rails/image.rb, line 34 def status_messages status[:description] end
success?()
click to toggle source
# File lib/clarifai/rails/image.rb, line 46 def success? error.blank? end
url()
click to toggle source
# File lib/clarifai/rails/image.rb, line 13 def url json[:input]['data']['image']['url'] rescue nil end
Private Instance Methods
data()
click to toggle source
# File lib/clarifai/rails/image.rb, line 54 def data json[:data].symbolize_keys end
status()
click to toggle source
# File lib/clarifai/rails/image.rb, line 58 def status json[:status].symbolize_keys end