class Fzy::Hay(T)

Overview

A hay in haystack, where you try to find a needle.

Defined in:

fzy/hay.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(item : T, key : String = item.to_s, bonus : Array(Float32) = Fzy.filepath_bonus(key)) forall T #

Initializes a Hay with a key, a reference to a item and a match bonus.


[View source]

Instance Method Detail

def bonus : Array(Float32) #

Match bonus, default to Fzy.filepath_bonus.


[View source]
def item : T #

Reference to the item this Hay represents.


[View source]
def key : String #

key used to match, always in lower case.


[View source]
def match?(downcase_needle : String, store_positions = false) : Match(T) | Nil #

Returns a Match(T) if downcase_needle matches.

To save some memory allocations the match doesn't save the matched character positions, to change that pass true to store_positions.

downcase_needle MUST be downcase for case insensitive search.


[View source]