Created
November 9, 2012 11:02
-
-
Save floere/4045154 to your computer and use it in GitHub Desktop.
Picky basic script example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'picky' | |
Person = Struct.new :id, :age, :name | |
data = Picky::Index.new :people do | |
category :age, partial: Picky::Partial::None.new | |
category :name | |
end | |
data.replace Person.new(1, 34, 'Florian') | |
data.replace Person.new(2, 77, 'Floris') | |
people = Picky::Search.new data | |
results = people.search '34 flori' # Takes around 0.0001s | |
p results # For logging | |
p results.allocations # => Returns ids, weight etc. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment