Sha256: a321717acb8bce0256511c59984ea01b50c854bd8850b294c18dc0541a5c4c53
Contents?: true
Size: 343 Bytes
Versions: 1
Compression:
Stored size: 343 Bytes
Contents
class String # break apart the string into strings of length `n` # # @example # 'foobar'.ngram(3) # # => ["-fo", "foo", "oob", "oba", "bar", "ar-"] def ngram(n) fail ArgumentError, "n must be > 1, is #{n}" if n < 2 str = "-#{self}-" (str.length - n + 1).times.map do |i| str.slice(i, n) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fuzzy_set-1.0.0 | lib/core_ext/string.rb |