Class: Services::Analyzer

Inherits:
Object
  • Object
show all
Defined in:
lib/services/analyzer.rb

Instance Method Summary collapse

Constructor Details

#initialize(result, threshold_adult, threshold_violence, threshold_face) ⇒ Analyzer

Returns a new instance of Analyzer.



5
6
7
8
9
10
# File 'lib/services/analyzer.rb', line 5

def initialize(result, threshold_adult, threshold_violence, threshold_face)
  @result = result
  @threshold_adult = threshold_adult
  @threshold_violence = threshold_violence
  @threshold_face = threshold_face
end

Instance Method Details

#callObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/services/analyzer.rb', line 12

def call
  result_hash = {}
  unless @result[:safe_search_annotation].nil?
    result_hash[:safe_search] = analyze_safe_search_annotation(@result[:safe_search_annotation])
  end

  unless @result[:face_annotations].nil?
    detection_confidence = @result[:face_annotations].first[:detection_confidence]
  end
  detection_confidence ||= 0

  result_hash[:face_recognised] = analyze_face_annotation(detection_confidence)
  result_hash
end