Class: Jubatus::NearestNeighbor::IdWithScore

Inherits:
Object
  • Object
show all
Includes:
Common
Defined in:
lib/jubatus/nearest_neighbor/types.rb

Constant Summary collapse

TYPE =
TTuple.new(TString.new, TFloat.new)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Common

check_type, check_types

Constructor Details

#initialize(id, score) ⇒ IdWithScore

Returns a new instance of IdWithScore.


15
16
17
18
# File 'lib/jubatus/nearest_neighbor/types.rb', line 15

def initialize(id, score)
  @id = id
  @score = score
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id


39
40
41
# File 'lib/jubatus/nearest_neighbor/types.rb', line 39

def id
  @id
end

#scoreObject (readonly)

Returns the value of attribute score


39
40
41
# File 'lib/jubatus/nearest_neighbor/types.rb', line 39

def score
  @score
end

Class Method Details

.from_msgpack(m) ⇒ Object


25
26
27
28
# File 'lib/jubatus/nearest_neighbor/types.rb', line 25

def IdWithScore.from_msgpack(m)
  val = TYPE.from_msgpack(m)
  IdWithScore.new(*val)
end

Instance Method Details

#to_msgpack(out = '') ⇒ Object


20
21
22
23
# File 'lib/jubatus/nearest_neighbor/types.rb', line 20

def to_msgpack(out = '')
  t = [@id, @score]
  return TYPE.to_msgpack(t)
end

#to_sObject


30
31
32
33
34
35
36
37
# File 'lib/jubatus/nearest_neighbor/types.rb', line 30

def to_s
  gen = Jubatus::Common::MessageStringGenerator.new
  gen.open("id_with_score")
  gen.add("id", @id)
  gen.add("score", @score)
  gen.close()
  return gen.to_s
end