Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/lederhosen.rb
Overview
Here I extend the string class to add the to_kmers method
Does it really need to be a method of String? Sure, why not?
Instance Method Summary collapse
Instance Method Details
#to_kmers(k) ⇒ Object
14 15 16 17 18 |
# File 'lib/lederhosen.rb', line 14 def to_kmers(k) return [] if k == 0 k -= 1 (0..(self.length-k-1)).collect { |i| self[i..i+k] } end |