class String
Public Instance Methods
cmpi(other)
click to toggle source
Compares strings ignoring case
@example
"test".cmpi("tesT") #=> true
# File lib/shenanigans/string/cmpi.rb, line 6 def cmpi(other) casecmp(other).zero? end
in_groups_of(size)
click to toggle source
Returns an array of the string broken down into groups of size
characters.
"aabbcc".in_groups_of(2) #=> ['aa', 'bb', 'cc'] "".in_groups_of(2) #=> [] "".in_groups_of(0) #=> ArgumentError
# File lib/shenanigans/string/in_groups_of.rb, line 7 def in_groups_of(size) raise ArgumentError, "Size of group must be >= 1" if size < 1 scan(/.{1,#{size}}/) end