Module: Gemmy::Patches::StringPatch::InstanceMethods::Rotate
- Defined in:
- lib/gemmy/patches/string_patch.rb
Instance Method Summary collapse
-
#rotate(count = 1) ⇒ Object
facets ‘abcdefgh’.rotate(2) #=> ‘cdefghab’ ‘abcdefgh’.rotate(-2) #=> ‘ghabcdef’.
Instance Method Details
#rotate(count = 1) ⇒ Object
facets ‘abcdefgh’.rotate(2) #=> ‘cdefghab’ ‘abcdefgh’.rotate(-2) #=> ‘ghabcdef’
93 94 95 96 |
# File 'lib/gemmy/patches/string_patch.rb', line 93 def rotate(count=1) count+=self.length if count<0 self.slice(count,self.length-count)+self.slice(0,count) end |