Class: Attune::Model::RankedEntities

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

Overview

List of ids in ranked order. If an error occurs, returns message and status code.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ RankedEntities

Returns a new instance of RankedEntities.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/attune/models/ranked_entities.rb', line 22

def initialize(attributes = {})
  return if attributes.empty?
  # Workaround since JSON.parse has accessors as strings rather than symbols
  @message = attributes["message"] || attributes[:"message"]
  # Workaround since JSON.parse has accessors as strings rather than symbols
  @cell = attributes["cell"] || attributes[:"cell"]
  value = attributes["ranking"] || attributes[:"ranking"]
  if value.is_a?(Array)
    @ranking = value

  end
  # Workaround since JSON.parse has accessors as strings rather than symbols
  @status = attributes["status"] || attributes[:"status"]
  

end

Instance Attribute Details

#cellString

Cell assignment

Returns:

  • (String)

    the current value of cell



9
10
11
# File 'lib/attune/models/ranked_entities.rb', line 9

def cell
  @cell
end

#messageString

Error message if ranking failed

Returns:

  • (String)

    the current value of message



9
10
11
# File 'lib/attune/models/ranked_entities.rb', line 9

def message
  @message
end

#rankingArray<String>

List of ids in ranked order

Returns:

  • (Array<String>)

    the current value of ranking



9
10
11
# File 'lib/attune/models/ranked_entities.rb', line 9

def ranking
  @ranking
end

#statusInteger

HTTP status code if ranking failed

Returns:

  • (Integer)

    the current value of status



9
10
11
# File 'lib/attune/models/ranked_entities.rb', line 9

def status
  @status
end

Instance Method Details

#to_bodyObject



39
40
41
42
43
44
# File 'lib/attune/models/ranked_entities.rb', line 39

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

#to_json(options = {}) ⇒ Object



46
47
48
# File 'lib/attune/models/ranked_entities.rb', line 46

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