Sha256: 8dcb387485315d8b99b3ba325b46ccd101a01f00ac027961edd50225daae6dda

Contents?: true

Size: 321 Bytes

Versions: 4

Compression:

Stored size: 321 Bytes

Contents

module Bluepill
  module Util
    class RotationalArray < Array
      def initialize(size)
        @capacity = size

        super() # no size - intentionally
      end

      def push(value)
        super(value)

        shift if length > @capacity
        self
      end
      alias_method :<<, :push
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
bluepill-0.1.2 lib/bluepill/util/rotational_array.rb
bluepill-0.1.1 lib/bluepill/util/rotational_array.rb
bluepill-0.0.70 lib/bluepill/util/rotational_array.rb
bluepill-0.0.69 lib/bluepill/util/rotational_array.rb