Class: Samer::Engine
- Inherits:
-
Object
- Object
- Samer::Engine
- Defined in:
- lib/samer/engine.rb
Instance Method Summary collapse
- #find_for(name) ⇒ Object
-
#initialize(users) ⇒ Engine
constructor
A new instance of Engine.
Constructor Details
#initialize(users) ⇒ Engine
Returns a new instance of Engine.
6 7 8 |
# File 'lib/samer/engine.rb', line 6 def initialize users @users = users end |
Instance Method Details
#find_for(name) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/samer/engine.rb', line 10 def find_for name similar = {} current_user = @users.find{ |user| user.name == name } @users.each do |user| next if user.name == current_user.name similar[user.name] = distance(current_user, user) end similar.max_by{ |_, score| score } end |