Module: Miu::Publisher
- Defined in:
- lib/miu/publisher.rb
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
-
#publisher ⇒ Object
readonly
Returns the value of attribute publisher.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#publisher ⇒ Object (readonly)
Returns the value of attribute publisher.
38 39 40 |
# File 'lib/miu/publisher.rb', line 38 def publisher @publisher end |
Class Method Details
.included(base) ⇒ Object
23 24 25 |
# File 'lib/miu/publisher.rb', line 23 def included(base) base.extend ClassMethods end |
.new(*args, &block) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/miu/publisher.rb', line 8 def new(*args, &block) = Miu::Utility. args host = args.shift || '127.0.0.1' port = args.shift || Miu.default_sub_port socket = [:socket] || PubSocket klass = Class.new(socket, &block) klass.send :include, Writable klass.new.tap do |pub| address = Miu::Socket.build_address host, port pub.connect address end end |
Instance Method Details
#close ⇒ Object
45 46 47 |
# File 'lib/miu/publisher.rb', line 45 def close @publisher.close end |
#initialize(host, port, tag) ⇒ Object
40 41 42 43 |
# File 'lib/miu/publisher.rb', line 40 def initialize(host, port, tag) @publisher = Miu::Publisher.new host, port, :socket => self.class.socket_type @tag = tag end |
#write(message) ⇒ Object
49 50 51 |
# File 'lib/miu/publisher.rb', line 49 def write() @publisher.write @tag, end |