module Levenshtein

Public Class Methods

distance(str1, str2) click to toggle source

Safe version of distance, checks that arguments are really strings.

# File lib/levenshtein.rb, line 13
def distance(str1, str2)
  validate(str1)
  validate(str2)
  ffi_distance(str1, str2)
end

Private Class Methods

validate(arg) click to toggle source
# File lib/levenshtein.rb, line 23
def validate(arg)
  unless arg.kind_of?(String)
    raise TypeError, "wrong argument type #{arg.class} (expected String)"
  end
end