Class: Qspec::IPC::File
- Inherits:
-
Qspec::IPC
- Object
- Qspec::IPC
- Qspec::IPC::File
- Defined in:
- lib/qspec/ipc/file.rb
Instance Method Summary collapse
- #del(key) ⇒ Object
-
#initialize(config) ⇒ File
constructor
A new instance of File.
- #llen(key) ⇒ Object
- #lpop(key) ⇒ Object
- #rpush(key, value) ⇒ Object
Methods inherited from Qspec::IPC
Constructor Details
#initialize(config) ⇒ File
Returns a new instance of File.
6 7 |
# File 'lib/qspec/ipc/file.rb', line 6 def initialize(config) end |
Instance Method Details
#del(key) ⇒ Object
9 10 11 |
# File 'lib/qspec/ipc/file.rb', line 9 def del(key) ::File.unlink(Qspec.path(key)) rescue nil end |
#llen(key) ⇒ Object
34 35 36 37 38 |
# File 'lib/qspec/ipc/file.rb', line 34 def llen(key) open(key, :r) do |f| safe_load(f).length end end |
#lpop(key) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/qspec/ipc/file.rb', line 13 def lpop(key) open(key, :rw) do |f| list = safe_load(f) f.truncate(0) f.rewind data = list.shift f.write(Marshal.dump(list)) data end end |
#rpush(key, value) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/qspec/ipc/file.rb', line 24 def rpush(key, value) open(key, :rw) do |f| list = safe_load(f) f.truncate(0) f.rewind list.push(value) f.write(Marshal.dump(list)) end end |