Sha256: b1a86ae342a82d119c418d27bf9886d36c58c42c568c849727905ea0763e8a76
Contents?: true
Size: 378 Bytes
Versions: 6
Compression:
Stored size: 378 Bytes
Contents
class String # Returns an array of the string broken down into groups of # <tt>size</tt> characters. # "aabbcc".in_groups_of(2) # #=> ['aa', 'bb', 'cc'] # "".in_groups_of(2) # #=> [] # "".in_groups_of(0) # #=> ArgumentError def in_groups_of(size) raise ArgumentError, "Size of group must be >= 1" if size < 1 scan(/.{1,#{size}}/) end end
Version data entries
6 entries across 6 versions & 1 rubygems