Class: InfluxDB::MaxQueue

Inherits:
Queue
  • Object
show all
Defined in:
lib/influxdb/max_queue.rb

Overview

Queue with max length limit

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(max = 10_000) ⇒ MaxQueue

Returns a new instance of MaxQueue.

Raises:

  • (ArgumentError)


6
7
8
9
10
11
# 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

#maxObject (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



13
14
15
# File 'lib/influxdb/max_queue.rb', line 13

def push(obj)
  super if length < @max
end