Class: AMQ::Protocol::FrameSubclass

Inherits:
Frame
  • Object
show all
Defined in:
lib/amq/protocol/frame.rb

Direct Known Subclasses

BodyFrame, HeaderFrame, HeartbeatFrame, MethodFrame

Constant Summary

Constants inherited from Frame

AMQ::Protocol::Frame::CHANNEL_RANGE, AMQ::Protocol::Frame::CLASSES, AMQ::Protocol::Frame::FINAL_OCTET, AMQ::Protocol::Frame::PACK_UINT64_BE, AMQ::Protocol::Frame::TYPES, AMQ::Protocol::Frame::TYPES_OPTIONS, AMQ::Protocol::Frame::TYPES_REVERSE

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Frame

#__new__, decode, decode_header, encode_to_array, encoded_payload, #final?, find_type

Constructor Details

#initialize(payload, channel) ⇒ FrameSubclass

Returns a new instance of FrameSubclass.



96
97
98
# File 'lib/amq/protocol/frame.rb', line 96

def initialize(payload, channel)
  @payload, @channel = payload, channel
end

Instance Attribute Details

#channelObject

Returns the value of attribute channel.



94
95
96
# File 'lib/amq/protocol/frame.rb', line 94

def channel
  @channel
end

#payloadObject (readonly)

Returns the value of attribute payload.



95
96
97
# File 'lib/amq/protocol/frame.rb', line 95

def payload
  @payload
end

Class Method Details

.encode(payload, channel) ⇒ Object



90
91
92
# File 'lib/amq/protocol/frame.rb', line 90

def self.encode(payload, channel)
  super(@id, payload, channel)
end

.idObject



86
87
88
# File 'lib/amq/protocol/frame.rb', line 86

def self.id
  @id
end

Instance Method Details

#encodeObject



115
116
117
118
119
120
# File 'lib/amq/protocol/frame.rb', line 115

def encode
  s = [self.class.id, @channel, @payload.bytesize].pack(PACK_CHAR_UINT16_UINT32)
  s << self.class.encoded_payload(@payload)
  s << FINAL_OCTET
  s
end

#encode_to_arrayObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

TODO: remove once we are sure none of the clients

uses this method directly


107
108
109
110
111
112
113
# File 'lib/amq/protocol/frame.rb', line 107

def encode_to_array
  components = []
  components << [self.class.id, @channel, @payload.bytesize].pack(PACK_CHAR_UINT16_UINT32)
  components << self.class.encoded_payload(@payload)
  components << FINAL_OCTET
  components
end

#sizeObject



100
101
102
# File 'lib/amq/protocol/frame.rb', line 100

def size
  @payload.bytesize
end