Class: Buster::Context
- Inherits:
-
Object
- Object
- Buster::Context
- Defined in:
- lib/buster/context.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
Returns the value of attribute context.
Instance Method Summary collapse
-
#initialize(context) ⇒ Context
constructor
A new instance of Context.
- #socket(type) ⇒ Object
- #terminate ⇒ Object
Constructor Details
#initialize(context) ⇒ Context
Returns a new instance of Context.
6 7 8 9 |
# File 'lib/buster/context.rb', line 6 def initialize(context) @context = context @sockets = [] end |
Instance Attribute Details
#context ⇒ Object
Returns the value of attribute context.
4 5 6 |
# File 'lib/buster/context.rb', line 4 def context @context end |
Instance Method Details
#socket(type) ⇒ Object
11 12 13 14 15 |
# File 'lib/buster/context.rb', line 11 def socket(type) socket = @context.socket(type) @sockets << socket socket end |
#terminate ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/buster/context.rb', line 17 def terminate @sockets.reverse.each do |s| s.setsockopt(ZMQ::LINGER, 0) s.close end @context.terminate end |