Module: GuessWho::Comparator

Defined in:
lib/guess_who/comparator.rb

Class Method Summary collapse

Class Method Details

.better?(contender, best, contender_length, best_length) ⇒ Boolean

Returns:

  • (Boolean)


3
4
5
6
7
8
9
10
11
# File 'lib/guess_who/comparator.rb', line 3

def self.better?(contender, best, contender_length, best_length)
  if contender >= best
    if contender == best # if the same score, go with simpler option
      contender_length <= best_length
    else # if not the same score, we have a winner!
      true
    end
  end
end