Sha256: f63300295f3cee2b97a023758f58bf275a93eaaeb6483c0baf85fc2bb6374bcd

Contents?: true

Size: 949 Bytes

Versions: 4

Compression:

Stored size: 949 Bytes

Contents

require 'erb'

class FuzzyMatch
  class Result #:nodoc: all
    EXPLANATION = <<-ERB
You looked for <%= needle.render.inspect %>

<% if winner %>It was matched with "<%= winner %>"<% else %>No match was found<% end %>

# THE HAYSTACK

The haystack reader was <%= read.inspect %>.

The haystack contained <%= haystack.length %> records like <%= haystack[0, 3].map(&:render).map(&:inspect).join(', ') %>

# HOW IT WAS MATCHED
<% timeline.each_with_index do |event, index| %>
(<%= index+1 %>) <%= event %>
<% end %>
ERB

    def timeline
      @timeline ||= []
    end

    attr_accessor :needle
    attr_accessor :read
    attr_accessor :haystack
    attr_accessor :options
    attr_accessor :normalizers
    attr_accessor :blockings
    attr_accessor :identities
    attr_accessor :stop_words
    attr_accessor :winner
    attr_accessor :score
    
    def explain
      $stdout.puts ::ERB.new(EXPLANATION, 0, '%<').result(binding)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fuzzy_match-1.3.1 lib/fuzzy_match/result.rb
fuzzy_match-1.3.0 lib/fuzzy_match/result.rb
fuzzy_match-1.2.2 lib/fuzzy_match/result.rb
fuzzy_match-1.2.1 lib/fuzzy_match/result.rb