Class: FuzzyMatch::Score

Inherits:
Object
  • Object
show all
Defined in:
lib/fuzzy_match/score.rb,
lib/fuzzy_match/score/amatch.rb,
lib/fuzzy_match/score/pure_ruby.rb

Direct Known Subclasses

Amatch, PureRuby

Defined Under Namespace

Classes: Amatch, PureRuby

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(str1, str2) ⇒ Score

Returns a new instance of Score.



9
10
11
12
# File 'lib/fuzzy_match/score.rb', line 9

def initialize(str1, str2)
  @str1 = str1.downcase
  @str2 = str2.downcase
end

Instance Attribute Details

#str1Object (readonly)

Returns the value of attribute str1.



6
7
8
# File 'lib/fuzzy_match/score.rb', line 6

def str1
  @str1
end

#str2Object (readonly)

Returns the value of attribute str2.



7
8
9
# File 'lib/fuzzy_match/score.rb', line 7

def str2
  @str2
end

Instance Method Details

#<=>(other) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/fuzzy_match/score.rb', line 14

def <=>(other)
  by_dices_coefficient = (dices_coefficient_similar <=> other.dices_coefficient_similar)
  if by_dices_coefficient == 0
    levenshtein_similar <=> other.levenshtein_similar
  else
    by_dices_coefficient
  end
end