Sha256: 51e92cc9fdaa22c5878e4933fade80bf5578e63fbdf5a5bdb51e47c3200b98d6

Contents?: true

Size: 562 Bytes

Versions: 11

Compression:

Stored size: 562 Bytes

Contents

module BELParser
  # Adds a levenshtein implementation based on which ruby engine is used.
  module Levenshtein

    unless self.methods.include?(:distance)

      if RUBY_ENGINE =~ /^jruby/i
        require 'levenshtein'
        define_singleton_method(:distance) do |string1, string2|
          ::Levenshtein.distance(string1, string2)
        end
      else
        require "damerau-levenshtein"
        define_singleton_method(:distance) do |string1, string2|
          ::DamerauLevenshtein.distance(string1, string2)
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
bel_parser-1.1.6-java lib/bel_parser/mixin/levenshtein.rb
bel_parser-1.1.6 lib/bel_parser/mixin/levenshtein.rb
bel_parser-1.1.5 lib/bel_parser/mixin/levenshtein.rb
bel_parser-1.1.4-java lib/bel_parser/mixin/levenshtein.rb
bel_parser-1.1.4 lib/bel_parser/mixin/levenshtein.rb
bel_parser-1.1.3-java lib/bel_parser/mixin/levenshtein.rb
bel_parser-1.1.3 lib/bel_parser/mixin/levenshtein.rb
bel_parser-1.1.2-java lib/bel_parser/mixin/levenshtein.rb
bel_parser-1.1.2 lib/bel_parser/mixin/levenshtein.rb
bel_parser-1.1.1-java lib/bel_parser/mixin/levenshtein.rb
bel_parser-1.1.1 lib/bel_parser/mixin/levenshtein.rb