Class: WebsocketRails::EventQueue

Inherits:
Object
  • Object
show all
Defined in:
lib/websocket_rails/event_queue.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeEventQueue

Returns a new instance of EventQueue.



6
7
8
# File 'lib/websocket_rails/event_queue.rb', line 6

def initialize
  @queue = []
end

Instance Attribute Details

#queueObject (readonly)

Returns the value of attribute queue.



4
5
6
# File 'lib/websocket_rails/event_queue.rb', line 4

def queue
  @queue
end

Instance Method Details

#enqueue(event) ⇒ Object Also known as: <<



10
11
12
# File 'lib/websocket_rails/event_queue.rb', line 10

def enqueue(event)
  @queue << event
end

#flush(&block) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/websocket_rails/event_queue.rb', line 23

def flush(&block)
  unless block.nil?
    @queue.each do |item|
      block.call item
    end
  end
  @queue = []
end

#lastObject



15
16
17
# File 'lib/websocket_rails/event_queue.rb', line 15

def last
  @queue.last
end

#sizeObject



19
20
21
# File 'lib/websocket_rails/event_queue.rb', line 19

def size
  @queue.size
end