Class: FuzzyMatch::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/fuzzy_match/result.rb

Overview

:nodoc: all

Constant Summary collapse

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeResult

Returns a new instance of Result.



34
35
36
# File 'lib/fuzzy_match/result.rb', line 34

def initialize
  @timeline = []
end

Instance Attribute Details

#groupingsObject

Returns the value of attribute groupings.



27
28
29
# File 'lib/fuzzy_match/result.rb', line 27

def groupings
  @groupings
end

#haystackObject

Returns the value of attribute haystack.



24
25
26
# File 'lib/fuzzy_match/result.rb', line 24

def haystack
  @haystack
end

#identitiesObject

Returns the value of attribute identities.



28
29
30
# File 'lib/fuzzy_match/result.rb', line 28

def identities
  @identities
end

#needleObject

Returns the value of attribute needle.



22
23
24
# File 'lib/fuzzy_match/result.rb', line 22

def needle
  @needle
end

#normalizersObject

Returns the value of attribute normalizers.



26
27
28
# File 'lib/fuzzy_match/result.rb', line 26

def normalizers
  @normalizers
end

#optionsObject

Returns the value of attribute options.



25
26
27
# File 'lib/fuzzy_match/result.rb', line 25

def options
  @options
end

#readObject

Returns the value of attribute read.



23
24
25
# File 'lib/fuzzy_match/result.rb', line 23

def read
  @read
end

#scoreObject

Returns the value of attribute score.



31
32
33
# File 'lib/fuzzy_match/result.rb', line 31

def score
  @score
end

#stop_wordsObject

Returns the value of attribute stop_words.



29
30
31
# File 'lib/fuzzy_match/result.rb', line 29

def stop_words
  @stop_words
end

#timelineObject (readonly)

Returns the value of attribute timeline.



32
33
34
# File 'lib/fuzzy_match/result.rb', line 32

def timeline
  @timeline
end

#winnerObject

Returns the value of attribute winner.



30
31
32
# File 'lib/fuzzy_match/result.rb', line 30

def winner
  @winner
end

Instance Method Details

#explainObject



38
39
40
# File 'lib/fuzzy_match/result.rb', line 38

def explain
  $stdout.puts ::ERB.new(EXPLANATION, 0, '%<').result(binding)
end