Class: Recommendify::Neighbor

Inherits:
Object
  • Object
show all
Defined in:
lib/recommendify/neighbor.rb

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Neighbor

Returns a new instance of Neighbor.



3
4
5
# File 'lib/recommendify/neighbor.rb', line 3

def initialize(data)
  @data = data
end

Instance Method Details

#<=>(other) ⇒ Object



15
16
17
# File 'lib/recommendify/neighbor.rb', line 15

def <=>(other)
  other.similarity <=> self.similarity
end

#item_idObject



7
8
9
# File 'lib/recommendify/neighbor.rb', line 7

def item_id
  @data.fetch(:item_id).to_s
end

#similarityObject



11
12
13
# File 'lib/recommendify/neighbor.rb', line 11

def similarity
  @data.fetch(:similarity)
end