Class: Attune::Model::BatchRankingResult

Inherits:
Object
  • Object
show all
Defined in:
lib/attune/models/batch_ranking_result.rb

Overview

Array of ranking results.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ BatchRankingResult

Returns a new instance of BatchRankingResult.



10
11
12
13
14
15
16
17
18
19
# File 'lib/attune/models/batch_ranking_result.rb', line 10

def initialize(attributes = {})
  return if attributes.empty?
  value = attributes["results"] || attributes[:"results"]
  if value.is_a?(Array)
    @results = value.map{ |v| RankedEntities.new(v) }

  end
  

end

Instance Attribute Details

#resultsArray<Attune::Model::RankedEntities>

Array of rankings in order of the parameters provided as input.

Returns:



6
7
8
# File 'lib/attune/models/batch_ranking_result.rb', line 6

def results
  @results
end

Instance Method Details

#to_bodyObject



21
22
23
24
25
26
# File 'lib/attune/models/batch_ranking_result.rb', line 21

def to_body
  Hash[ATTRIBUTE_MAP.map do |internal, external|
    next unless value = send(internal)
    [external, value]
  end.compact]
end

#to_json(options = {}) ⇒ Object



28
29
30
# File 'lib/attune/models/batch_ranking_result.rb', line 28

def to_json(options = {})
  to_body.to_json
end