Class: JsTestServer::Server::Resources::RemoteControl::Queue
- Inherits:
-
Object
- Object
- JsTestServer::Server::Resources::RemoteControl::Queue
- Defined in:
- lib/js_test_server/server/resources/remote_control.rb
Instance Method Summary collapse
- #clear ⇒ Object
-
#initialize ⇒ Queue
constructor
A new instance of Queue.
- #push(item) ⇒ Object (also: #<<)
- #subscribe(&blk) ⇒ Object
- #to_a ⇒ Object
- #unsubscribe ⇒ Object
Constructor Details
#initialize ⇒ Queue
Returns a new instance of Queue.
6 7 8 9 |
# File 'lib/js_test_server/server/resources/remote_control.rb', line 6 def initialize @items = [] @subscriber = nil end |
Instance Method Details
#clear ⇒ Object
22 23 24 25 |
# File 'lib/js_test_server/server/resources/remote_control.rb', line 22 def clear items, @items = @items, [] items end |
#push(item) ⇒ Object Also known as: <<
10 11 12 13 |
# File 'lib/js_test_server/server/resources/remote_control.rb', line 10 def push item @items << item notify_subscriber if @subscriber end |
#subscribe(&blk) ⇒ Object
15 16 17 18 |
# File 'lib/js_test_server/server/resources/remote_control.rb', line 15 def subscribe &blk @subscriber = blk notify_subscriber unless @items.empty? end |
#to_a ⇒ Object
26 27 28 |
# File 'lib/js_test_server/server/resources/remote_control.rb', line 26 def to_a @items end |
#unsubscribe ⇒ Object
19 20 21 |
# File 'lib/js_test_server/server/resources/remote_control.rb', line 19 def unsubscribe @subscriber = nil end |