Class: Restruct::Queue
Instance Attribute Summary
Attributes inherited from Structure
#connection, #id
Instance Method Summary
collapse
Methods inherited from Structure
#==, #destroy, #dump, #exists?, #initialize, #restore
Instance Method Details
#empty? ⇒ Boolean
18
19
20
|
# File 'lib/restruct/queue.rb', line 18
def empty?
size == 0
end
|
#pop ⇒ Object
8
9
10
|
# File 'lib/restruct/queue.rb', line 8
def pop
deserialize connection.lazy('LPOP', id)
end
|
#push(object) ⇒ Object
4
5
6
|
# File 'lib/restruct/queue.rb', line 4
def push(object)
connection.lazy 'RPUSH', id, serialize(object)
end
|
#size ⇒ Object
Also known as:
count, length
12
13
14
|
# File 'lib/restruct/queue.rb', line 12
def size
connection.call 'LLEN', id
end
|
#to_a ⇒ Object
Also known as:
to_primitive
22
23
24
|
# File 'lib/restruct/queue.rb', line 22
def to_a
connection.call('LRANGE', id, 0, -1).map { |o| deserialize o }
end
|