Class: InfluxDB::MaxQueue
- Inherits:
-
Queue
- Object
- Queue
- InfluxDB::MaxQueue
- Defined in:
- lib/influxdb/max_queue.rb
Overview
Queue with max length limit
Instance Attribute Summary collapse
-
#max ⇒ Object
readonly
Returns the value of attribute max.
Instance Method Summary collapse
-
#initialize(max = 10_000) ⇒ MaxQueue
constructor
A new instance of MaxQueue.
- #push(obj) ⇒ Object
Constructor Details
#initialize(max = 10_000) ⇒ MaxQueue
Returns a new instance of MaxQueue.
6 7 8 9 10 |
# File 'lib/influxdb/max_queue.rb', line 6 def initialize(max = 10_000) raise ArgumentError, "queue size must be positive" if max <= 0 @max = max super() end |
Instance Attribute Details
#max ⇒ Object (readonly)
Returns the value of attribute max.
4 5 6 |
# File 'lib/influxdb/max_queue.rb', line 4 def max @max end |
Instance Method Details
#push(obj) ⇒ Object
12 13 14 |
# File 'lib/influxdb/max_queue.rb', line 12 def push(obj) super if length < @max end |