Class: CognitiveVision::AnalyzeResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/cognitive_vision/analyze_response.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ AnalyzeResponse

Returns a new instance of AnalyzeResponse.



5
6
7
8
9
10
11
# File 'lib/cognitive_vision/analyze_response.rb', line 5

def initialize(options = {})
  @adult       = options.fetch(:adult, nil)
  @categories  = options.fetch(:categories, [])
  @description = options.fetch(:description, nil)
  @faces       = options.fetch(:faces, [])
  @tags        = options.fetch(:tags, [])
end

Instance Attribute Details

#adultObject (readonly)

Returns the value of attribute adult.



3
4
5
# File 'lib/cognitive_vision/analyze_response.rb', line 3

def adult
  @adult
end

#categoriesObject (readonly)

Returns the value of attribute categories.



3
4
5
# File 'lib/cognitive_vision/analyze_response.rb', line 3

def categories
  @categories
end

#descriptionObject (readonly)

Returns the value of attribute description.



3
4
5
# File 'lib/cognitive_vision/analyze_response.rb', line 3

def description
  @description
end

#facesObject (readonly)

Returns the value of attribute faces.



3
4
5
# File 'lib/cognitive_vision/analyze_response.rb', line 3

def faces
  @faces
end

#tagsObject (readonly)

Returns the value of attribute tags.



3
4
5
# File 'lib/cognitive_vision/analyze_response.rb', line 3

def tags
  @tags
end

Class Method Details

.parse(response_hash, features) ⇒ Object



13
14
15
16
17
18
# File 'lib/cognitive_vision/analyze_response.rb', line 13

def self.parse(response_hash, features)
  parsed = features.analyzers.map do |analyzer|
             [analyzer.key.to_sym, analyzer.parse(response_hash)]
           end
  new(Hash[parsed])
end