Method: String#rotate
- Defined in:
- lib/core/facets/string/rotate.rb
#rotate(count = 1) ⇒ Object
Rotate string to the left with count. Specifying negative number indicates rotation to the right.
'abcdefgh'.rotate(2) #=> 'cdefghab'
'abcdefgh'.rotate(-2) #=> 'ghabcdef'
CREDIT: T. Yamada
10 11 12 13 |
# File 'lib/core/facets/string/rotate.rb', line 10 def rotate(count=1) count+=self.length if count<0 self.slice(count,self.length-count)+self.slice(0,count) end |