Class: RubyVolt::Message

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

Direct Known Subclasses

InvocationRequest, LoginMessage

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Message



5
6
7
8
# File 'lib/ruby_volt/message.rb', line 5

def initialize(*args)
  @protocol = args[0]
  @msg = ::String.new
end

Instance Attribute Details

#msgObject (readonly)

Returns the value of attribute msg.



3
4
5
# File 'lib/ruby_volt/message.rb', line 3

def msg
  @msg
end

#protocolObject (readonly)

Returns the value of attribute protocol.



3
4
5
# File 'lib/ruby_volt/message.rb', line 3

def protocol
  @protocol
end

Instance Method Details

#inspectObject



10
11
12
# File 'lib/ruby_volt/message.rb', line 10

def inspect
  to_str.dump
end

#to_strObject



14
15
16
# File 'lib/ruby_volt/message.rb', line 14

def to_str
  msg
end

#wrap {|msg| ... } ⇒ Object

Yields:



18
19
20
21
22
23
# File 'lib/ruby_volt/message.rb', line 18

def wrap(&block)
  msg << DataType::Byte.pack(protocol) # VoltDB Wire Protocol Version
  yield(msg)
  msg.prepend(DataType::Integer.pack(msg.bytesize)) # Message length preceded
  self
end