class SlackBotServer::LocalQueue
A local implementation of a queue.
Obviously this can't be used to communicate between multiple processes, let alone multiple machines, but it serves to demonstrate the expected API.
Public Class Methods
new()
click to toggle source
Creates a new local in-memory queue
# File lib/slack_bot_server/local_queue.rb, line 8 def initialize @queue = Queue.new end
Public Instance Methods
clear()
click to toggle source
Clear the queue @return [nil]
# File lib/slack_bot_server/local_queue.rb, line 27 def clear @queue = Queue.new end
pop()
click to toggle source
Pop a value from the front of the queue @return [Object, nil] returns the object from the front of the
queue, or nil if the queue is empty
# File lib/slack_bot_server/local_queue.rb, line 20 def pop value = @queue.pop(true) rescue ThreadError value == ThreadError ? nil : value end
push(value)
click to toggle source
Push a value onto the back of the queue
# File lib/slack_bot_server/local_queue.rb, line 13 def push(value) @queue << value end