Converts a list of strings into a compact, readable representation with delimiters of choice
bocadillo 'alba,albero,albergo,alberto'
# => alb(a|er(go|o|to))
bocadillo 'aria:arianna' ':' '[' '+' ']'
# => aria[+nna]
In Spanish, bocadillo means sandwich. The name hints at the strings being sliced and interleaved with bread, the delimiters. Bocadillo is the Ruby port of the PHP package Tramezzino.
Useful when you need to pass long lists of URL params
Add it to your Ruby project as a Ruby Gem:
gem install bocadillo
Then have it your way:
require 'bocadillo'
encoded = Bocadillo.encode(['alba', 'albero', 'albergo', 'alberto'])
# => encoded == 'alb(a|er(go|o|to))'
The bocadillo
gem also installs a bocadillo
command:
$ bocadillo 'alba,albero,albino'
alb(a|ero|ino)
Copyright (c) 2017, Claudio Procida