0.0
No commit activity in last 3 years
No release in over 3 years
This gem provides fast prefix-autocompletion in pure ruby.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

README

Summary

This gem provides fast prefix-autocompletion in pure ruby.

Installation

gem install autocompletion

Usage

Autocomplete words

auto = AutoCompletion.words(%w[foo bar baz])
auto.complete('f') # => ["foo"]
auto.complete('b') # => ["bar", "baz"]
auto.complete('z') # => []

Autocomplete objects by attributes

Person  = Struct.new(:first_name, :last_name)
people  = [
  Person.new("Peter", "Parker"),
  Person.new("Luke", "Skywalker"),
  Person.new("Anakin", "Skywalker"),
]
auto    = AutoCompletion.map_keys(people) { |person|
  [person.first_name, person.last_name]
}

auto.complete("P")
# => [#<struct Person first_name="Peter", last_name="Parker">]

auto.complete("S")
# => [#<struct Person first_name="Luke", last_name="Skywalker">,
#     #<struct Person first_name="Anakin", last_name="Skywalker">]

auto.complete("S", "L")
# => [#<struct Person first_name="Luke", last_name="Skywalker">]

Links