Class: RbZMQ::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/rbzmq/message.rb

Overview

RbZMQ::Message

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(str = '') ⇒ Message

Returns a new instance of Message.


9
10
11
12
13
14
15
16
# File 'lib/rbzmq/message.rb', line 9

def initialize(str = '')
  if str.is_a?(ZMQ::Message)
    @data = str.copy_out_string
    str.close
  else
    @data = str.to_s
  end
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data


7
8
9
# File 'lib/rbzmq/message.rb', line 7

def data
  @data
end

Class Method Details

.new(*args) ⇒ RbZMQ::Message

Create new RbZMQ::Message.

If first argument is a RbZMQ::Message object it will be returned instead of a new one.

Returns:


35
36
37
38
# File 'lib/rbzmq/message.rb', line 35

def new(*args)
  return args[0] if args[0].is_a?(self)
  super
end

Instance Method Details

#to_sObject


18
19
20
# File 'lib/rbzmq/message.rb', line 18

def to_s
  data
end

#to_zmqObject


22
23
24
# File 'lib/rbzmq/message.rb', line 22

def to_zmq
  ZMQ::Message.new(data)
end