Class: Lens::Worker::Queue
- Inherits:
-
Queue
- Object
- Queue
- Lens::Worker::Queue
- Defined in:
- lib/lens/worker.rb
Overview
A queue which enforces a maximum size. NOTE: can be replaced with SizedQueue?
Instance Attribute Summary collapse
-
#max_size ⇒ Object
readonly
Returns the value of attribute max_size.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Queue
constructor
A new instance of Queue.
- #push(obj) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Queue
Returns a new instance of Queue.
8 9 10 11 12 13 |
# File 'lib/lens/worker.rb', line 8 def initialize( = {}) raise ArgumentError unless [:max_size] @max_size = [:max_size] super() end |
Instance Attribute Details
#max_size ⇒ Object (readonly)
Returns the value of attribute max_size.
6 7 8 |
# File 'lib/lens/worker.rb', line 6 def max_size @max_size end |
Instance Method Details
#push(obj) ⇒ Object
15 16 17 |
# File 'lib/lens/worker.rb', line 15 def push(obj) super unless size >= max_size end |