Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/konapun/autocomplete
- Owner: konapun
- Created: 2015-05-15T02:16:44.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-06-02T02:15:53.000Z (over 9 years ago)
- Last Synced: 2024-10-16T17:54:35.786Z (2 months ago)
- Language: Ruby
- Size: 125 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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 = falseca = 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']
```