Class: RubyVolt::Message
- Inherits:
-
Object
- Object
- RubyVolt::Message
- Defined in:
- lib/ruby_volt/message.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#msg ⇒ Object
readonly
Returns the value of attribute msg.
-
#protocol ⇒ Object
readonly
Returns the value of attribute protocol.
Instance Method Summary collapse
-
#initialize(*args) ⇒ Message
constructor
A new instance of Message.
- #inspect ⇒ Object
- #to_str ⇒ Object
- #wrap {|msg| ... } ⇒ Object
Constructor Details
#initialize(*args) ⇒ Message
Returns a new instance of 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
#msg ⇒ Object (readonly)
Returns the value of attribute msg.
3 4 5 |
# File 'lib/ruby_volt/message.rb', line 3 def msg @msg end |
#protocol ⇒ Object (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
#inspect ⇒ Object
10 11 12 |
# File 'lib/ruby_volt/message.rb', line 10 def inspect to_str.dump end |
#to_str ⇒ Object
14 15 16 |
# File 'lib/ruby_volt/message.rb', line 14 def to_str msg end |
#wrap {|msg| ... } ⇒ Object
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 |