Class: SaveQueue::UniqQueue
- Inherits:
-
Object
- Object
- SaveQueue::UniqQueue
- Extended by:
- Forwardable
- Defined in:
- lib/save_queue/uniq_queue.rb
Direct Known Subclasses
Constant Summary collapse
- DELEGATED_METHODS =
[:empty?, :any?, :size, :count, :clear, :inspect, :to_s, :first, :last, :pop, :shift]
Instance Method Summary collapse
- #<<(*args) ⇒ Object
- #add(object) ⇒ Object
- #add_all(objects) ⇒ Object
-
#initialize ⇒ UniqQueue
constructor
A new instance of UniqQueue.
-
#push(*args) ⇒ Object
alias_method :push, :add # Not working as expected: does not save inheritance.
Constructor Details
#initialize ⇒ UniqQueue
Returns a new instance of UniqQueue.
19 20 21 |
# File 'lib/save_queue/uniq_queue.rb', line 19 def initialize @queue = [] end |
Instance Method Details
#<<(*args) ⇒ Object
41 42 43 44 |
# File 'lib/save_queue/uniq_queue.rb', line 41 def << *args add *args self end |
#add(object) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/save_queue/uniq_queue.rb', line 29 def add object return false if @queue.include? object @queue << object true end |
#add_all(objects) ⇒ Object
23 24 25 26 27 |
# File 'lib/save_queue/uniq_queue.rb', line 23 def add_all objects Array(objects).each do |object| add object end end |
#push(*args) ⇒ Object
alias_method :push, :add # Not working as expected: does not save inheritance
37 38 39 |
# File 'lib/save_queue/uniq_queue.rb', line 37 def push(*args) add *args end |