Skip to content

Instantly share code, notes, and snippets.

Last active August 29, 2015 14:00
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Picky Example
#!/usr/bin/env ruby
require 'picky'
# create an index which is auto-saved into './index'
# note that :id is implied - every input object must supply an :id !
index = :people do
category :age
category :name
# define a data input class
# any object that responds to :id, :age, :name can be added to the index.
Person = :id, :age, :name
# add some data objects to the index
# note that the IDs can be any unique string or integer
index.add, 34, 'Florian is the author of picky')
index.add, 77, 'Floris is related to Florian')
# create a search object
people = index
# do a search and save the results
search_results = 'floris'
# show the results
puts search_results.ids
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment