Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/ngrams/stdlib_ext.rb
Instance Method Summary collapse
-
#ngrams(n) ⇒ Object
Return the result of splitting the string into an array of ngrams of length n.
Instance Method Details
#ngrams(n) ⇒ Object
Return the result of splitting the string into an array of ngrams of length n.
7 8 9 |
# File 'lib/ngrams/stdlib_ext.rb', line 7 def ngrams( n ) (0..self.length-n).to_a.collect { |idx| self[idx,n] } end |