Module: Gemmy::Patches::StringPatch::InstanceMethods::Rotate

Defined in:
lib/gemmy/patches/string_patch.rb

Instance Method Summary collapse

Instance Method Details

#rotate(count = 1) ⇒ Object

facets ‘abcdefgh’.rotate(2) #=> ‘cdefghab’ ‘abcdefgh’.rotate(-2) #=> ‘ghabcdef’



87
88
89
90
# File 'lib/gemmy/patches/string_patch.rb', line 87

def rotate(count=1)
  count+=self.length if count<0
  self.slice(count,self.length-count)+self.slice(0,count)
end