module Binary::Protocol
Constants
- BYTES_16
- BYTES_32
- BYTES_64
- BYTES_8
- DOUBLEBE_PACK
- DOUBLELE_PACK
- DOUBLE_PACK
- INT16BE_PACK
- INT16LE_PACK
- INT16_PACK
- INT32BE_PACK
- INT32LE_PACK
- INT32_PACK
- INT64BE_PACK
- INT64LE_PACK
- INT64_PACK
- INT8_PACK
- SINGLEBE_PACK
- SINGLELE_PACK
- SINGLE_PACK
- UINT16BE_PACK
- UINT16LE_PACK
- UINT16_PACK
- UINT32BE_PACK
- UINT32LE_PACK
- UINT32_PACK
- UINT64BE_PACK
- UINT64LE_PACK
- UINT64_PACK
- UINT8_PACK
- VERSION
Private Class Methods
included(base)
click to toggle source
Extends the including class with ClassMethods
.
@param [Class] subclass the inheriting class
Calls superclass method
# File lib/binary/protocol.rb, line 46 def included(base) super base.extend ClassMethods end
Public Instance Methods
deserialize(buffer)
click to toggle source
# File lib/binary/protocol.rb, line 362 def deserialize(buffer) self.class.fields.each do |field| __send__(:"deserialize_#{field}", buffer) end self end
inspect()
click to toggle source
@return [String] the nicely formatted version of the message
# File lib/binary/protocol.rb, line 380 def inspect fields = self.class.fields.map do |field| "@#{field}=" + __send__(field).inspect end "#<#{self.class.name} " << "#{fields * " "}>" end
pretty_inspect()
click to toggle source
# File lib/binary/protocol.rb, line 388 def pretty_inspect fields = self.class.fields.map do |field| "@#{field}=" + __send__(field).inspect end "#<#{self.class.name}\n" << " #{fields * "\n "}>" end
receive_replies(connection)
click to toggle source
Default implementation for a message is to do nothing when receiving replies.
@example Receive replies.
message.receive_replies(connection)
@param [ Connection ] connection The connection.
@since 1.0.0
@return [ nil ] nil.
# File lib/binary/protocol.rb, line 360 def receive_replies(connection); end
serialize(buffer = "")
click to toggle source
Serializes the message and all of its fields to a new buffer or to the provided buffer.
@param [String] buffer a buffer to serialize to @return [String] the result of serliazing this message
# File lib/binary/protocol.rb, line 374 def serialize(buffer = "") raise NotImplementedError, "This method is generated after calling #finalize on a message class" end
Also aliased as: to_s