Sha256: b1b1f74dc26a7ffdbc6a02ecce762e7361575c897916cfb5567bf2e84fe2645f

Contents?: true

Size: 683 Bytes

Versions: 8

Compression:

Stored size: 683 Bytes

Contents

require 'fuzzy_match/score/pure_ruby'
require 'fuzzy_match/score/amatch'

class FuzzyMatch
  class Score
    include Comparable
    
    attr_reader :str1
    attr_reader :str2

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

    def inspect
      %{(dice=#{"%0.5f" % dices_coefficient_similar},lev=#{"%0.5f" % levenshtein_similar})}
    end

    def <=>(other)
      a = dices_coefficient_similar
      b = other.dices_coefficient_similar
      if a.nan? or b.nan? or (by_dices_coefficient = (a <=> b)) == 0
        levenshtein_similar <=> other.levenshtein_similar
      else
        by_dices_coefficient
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
cocoapods-dependency-html-0.0.2 vendor/bundle/gems/fuzzy_match-2.0.4/lib/fuzzy_match/score.rb
cocoapods-dependency-html-0.0.1 vendor/bundle/gems/fuzzy_match-2.0.4/lib/fuzzy_match/score.rb
fuzzy_match-2.1.0 lib/fuzzy_match/score.rb
fuzzy_match-2.0.4 lib/fuzzy_match/score.rb
fuzzy_match-2.0.3 lib/fuzzy_match/score.rb
fuzzy_match-2.0.2 lib/fuzzy_match/score.rb
fuzzy_match-2.0.1 lib/fuzzy_match/score.rb
fuzzy_match-2.0.0 lib/fuzzy_match/score.rb