Class: Recommendify::Neighbor
- Inherits:
-
Object
- Object
- Recommendify::Neighbor
- Defined in:
- lib/recommendify/neighbor.rb
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(data) ⇒ Neighbor
constructor
A new instance of Neighbor.
- #item_id ⇒ Object
- #similarity ⇒ Object
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_id ⇒ Object
7 8 9 |
# File 'lib/recommendify/neighbor.rb', line 7 def item_id @data.fetch(:item_id).to_s end |
#similarity ⇒ Object
11 12 13 |
# File 'lib/recommendify/neighbor.rb', line 11 def similarity @data.fetch(:similarity) end |