Class: FzyScore::Match

Inherits:
Struct
  • Object
show all
Defined in:
lib/fzy_score/match.rb

Overview

Result of a scored fuzzy match.

score Float relevance score. Higher is better. SCORE_MAX for an

exact (case-insensitive) match, {SCORE_MIN} for no match / empty
needle / oversized candidate.

positions Array<Integer> of the indices in haystack that the needle

matched, suitable for highlighting. +nil+ unless positions were
requested.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#positionsObject

Returns the value of attribute positions

Returns:

  • (Object)

    the current value of positions



12
13
14
# File 'lib/fzy_score/match.rb', line 12

def positions
  @positions
end

#scoreObject

Returns the value of attribute score

Returns:

  • (Object)

    the current value of score



12
13
14
# File 'lib/fzy_score/match.rb', line 12

def score
  @score
end

Instance Method Details

#matched?Boolean

Returns true when the candidate actually matched.

Returns:

  • (Boolean)

    true when the candidate actually matched.



14
15
16
# File 'lib/fzy_score/match.rb', line 14

def matched?
  score > SCORE_MIN
end