Class: Docker::Registry::Sync::RingBuffer
- Inherits:
-
Array
- Object
- Array
- Docker::Registry::Sync::RingBuffer
- Defined in:
- lib/docker/registry/sync.rb
Instance Attribute Summary collapse
-
#max_size ⇒ Object
readonly
Returns the value of attribute max_size.
Instance Method Summary collapse
- #<<(el) ⇒ Object (also: #push)
-
#initialize(max_size, enum = nil) ⇒ RingBuffer
constructor
A new instance of RingBuffer.
Constructor Details
#initialize(max_size, enum = nil) ⇒ RingBuffer
Returns a new instance of RingBuffer.
11 12 13 14 |
# File 'lib/docker/registry/sync.rb', line 11 def initialize(max_size, enum = nil) @max_size = max_size enum.each { |e| self << e } if enum end |
Instance Attribute Details
#max_size ⇒ Object (readonly)
Returns the value of attribute max_size.
9 10 11 |
# File 'lib/docker/registry/sync.rb', line 9 def max_size @max_size end |
Instance Method Details
#<<(el) ⇒ Object Also known as: push
16 17 18 19 20 21 22 23 |
# File 'lib/docker/registry/sync.rb', line 16 def <<(el) if self.size < @max_size || @max_size.nil? super else self.shift self.push(el) end end |