Sha256: b259ee8df98c9f42614c754487805fc4c6627dd826aaf9d7595221aa4e03b71d

Contents?: true

Size: 365 Bytes

Versions: 3

Compression:

Stored size: 365 Bytes

Contents

# -*- encoding: utf-8 -*-

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

        super() # no size - intentionally
      end

      def push(value)
        super(value)

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
evented_bluepill-0.0.52 lib/evented_bluepill/util/rotational_array.rb
evented_bluepill-0.0.51 lib/evented_bluepill/util/rotational_array.rb
evented_bluepill-0.0.50 lib/evented_bluepill/util/rotational_array.rb