class FuzzyStringMatch::JaroWinkler

Public Class Methods

create( type = :pure ) click to toggle source
# File lib/fuzzystringmatch.rb, line 22
def self.create( type = :pure )     # factory method
  case type
  when :pure
    FuzzyStringMatch::JaroWinklerPure.new

  when :native
    if RUBY_PLATFORM == "java"
      STDERR.puts "fuzzy-string-match Warning: native version is disabled on java platform. falled back to pure ruby version..."
      FuzzyStringMatch::JaroWinklerPure.new
    else
      begin
        require 'fuzzystringmatch/inline'
        begin
          FuzzyStringMatch::JaroWinklerInline.new
        rescue NameError
          STDERR.puts "fuzzy-string-match Warning: native version is disabled. falled back to pure ruby version..."
          FuzzyStringMatch::JaroWinklerPure.new
        end
      rescue CompilationError
        STDERR.puts "fuzzy-string-match Warning: fallback into pure version, because compile failed."
        FuzzyStringMatch::JaroWinklerPure.new
      end
    end
  end

end