Class: Attune::Model::BatchRankingResult
- Inherits:
-
Object
- Object
- Attune::Model::BatchRankingResult
- Defined in:
- lib/attune/models/batch_ranking_result.rb
Overview
Array of ranking results.
Instance Attribute Summary collapse
-
#results ⇒ Array<Attune::Model::RankedEntities>
Array of rankings in order of the parameters provided as input.
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ BatchRankingResult
constructor
A new instance of BatchRankingResult.
- #to_body ⇒ Object
- #to_json(options = {}) ⇒ Object
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
#results ⇒ Array<Attune::Model::RankedEntities>
Array of rankings in order of the parameters provided as input.
6 7 8 |
# File 'lib/attune/models/batch_ranking_result.rb', line 6 def results @results end |
Instance Method Details
#to_body ⇒ Object
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( = {}) to_body.to_json end |