Sha256: e0c6218f5234c763d0812c22a36aa543bd51efd0c7af65df8f5dd3b0bc087844

Contents?: true

Size: 658 Bytes

Versions: 2

Compression:

Stored size: 658 Bytes

Contents

class Array
  
  # backport of Ruby 1.9.2 Array#rotate
  unless [].respond_to?(:rotate)
    def rotate(n=1)
      n = (n % self.size)
      n>0 ? self[n..-1] + self[0...n] : self
    end
  end
  unless [].respond_to?(:rotate!)
    def rotate!(n=1)
      self.replace(self.rotate(n))
    end
  end
  
  # backport of Ruby 1.8.7 Array#index(){...}
  if_ruby_version :<, '1.8.7' do
    unless [].respond_to?(:index_without_block)
      alias index_without_block index
      def index(*args, &blk)
        if args.empty?
          index_without_block(find(&blk))
        else
          index_without_block(*args, &blk)
        end
      end
    end
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
modalsupport-0.7.1 lib/modalsupport/array.rb
modalsupport-0.7.0 lib/modalsupport/array.rb