Class: Bugsnag::Utility::CircularBuffer Private
- Inherits:
-
Object
- Object
- Bugsnag::Utility::CircularBuffer
- Includes:
- Enumerable
- Defined in:
- lib/bugsnag/utility/circular_buffer.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
A container class with a maximum size, that removes oldest items as required.
Instance Attribute Summary collapse
-
#max_items ⇒ Integer
private
The current maximum allowable number of items.
Instance Method Summary collapse
-
#<<(item) ⇒ self
private
Adds an item to the circular buffer.
-
#each {|Object| ... } ⇒ Object
private
Iterates over the buffer.
-
#initialize(max_items = 25) ⇒ CircularBuffer
constructor
private
A new instance of CircularBuffer.
Constructor Details
#initialize(max_items = 25) ⇒ CircularBuffer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of CircularBuffer.
14 15 16 17 |
# File 'lib/bugsnag/utility/circular_buffer.rb', line 14 def initialize(max_items = 25) @max_items = max_items @buffer = [] end |
Instance Attribute Details
#max_items ⇒ Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the current maximum allowable number of items.
10 11 12 |
# File 'lib/bugsnag/utility/circular_buffer.rb', line 10 def max_items @max_items end |
Instance Method Details
#<<(item) ⇒ self
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Adds an item to the circular buffer
If this causes the buffer to exceed its maximum items, the oldest item will be removed
26 27 28 29 30 |
# File 'lib/bugsnag/utility/circular_buffer.rb', line 26 def <<(item) @buffer << item trim_buffer self end |
#each {|Object| ... } ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Iterates over the buffer
36 37 38 |
# File 'lib/bugsnag/utility/circular_buffer.rb', line 36 def each(&block) @buffer.each(&block) end |