Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/konapun/autocomplete

Get autocomplete suggestions for a string given an array of possible values
https://github.com/konapun/autocomplete

Last synced: 23 days ago
JSON representation

Get autocomplete suggestions for a string given an array of possible values

Awesome Lists containing this project

README

        

# autocomplete
Get autocomplete suggestions for a string given an array of possible values

## Usage
```ruby
ac = Autocomplete.new(['can', 'Canada', 'soda', 'sock', 'song', 'sound', 'sand', 'zebra'])

# By default, suggestions are case-sensitive. Make results case-insentitive by:
ac.case_sensitive = false

ca = ac.autocomplete('ca') # => ['can', 'Canada']
so = ac.autocomplete('so') # => ['soda', 'sock', 'song', 'sound']
s = ac.autocomplete('s') # => ['soda', 'sock', 'song', 'sound', 'sand']
```

If you'd like to search a corpus for a string appearing in any position, run `autocomplete` with the optional second
argument set to `true`

```ruby
ou = ac.autocomplete('ou', true) # => ['sound']
```