Class: AMQ::Protocol::Basic::Nack

Inherits:
Method
  • Object
show all
Defined in:
lib/amq/protocol/client.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Method

encode_body, index, inherited, instantiate, method_id, methods, name, split_headers

Constructor Details

#initialize(delivery_tag, multiple, requeue) ⇒ Nack

Returns a new instance of Nack.



2156
2157
2158
2159
2160
# File 'lib/amq/protocol/client.rb', line 2156

def initialize(delivery_tag, multiple, requeue)
  @delivery_tag = delivery_tag
  @multiple = multiple
  @requeue = requeue
end

Instance Attribute Details

#delivery_tagObject (readonly)

Returns the value of attribute delivery_tag.



2155
2156
2157
# File 'lib/amq/protocol/client.rb', line 2155

def delivery_tag
  @delivery_tag
end

#multipleObject (readonly)

Returns the value of attribute multiple.



2155
2156
2157
# File 'lib/amq/protocol/client.rb', line 2155

def multiple
  @multiple
end

#requeueObject (readonly)

Returns the value of attribute requeue.



2155
2156
2157
# File 'lib/amq/protocol/client.rb', line 2155

def requeue
  @requeue
end

Class Method Details

.decode(data) ⇒ Object

Returns:



2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
# File 'lib/amq/protocol/client.rb', line 2144

def self.decode(data)
  offset = offset = 0 # self-assigning offset to eliminate "assigned but unused variable" warning even if offset is not used in this method
  delivery_tag = AMQ::Pack.unpack_uint64_big_endian(data[offset, 8]).first
  offset += 8
  bit_buffer = data[offset, 1].unpack(PACK_CHAR).first
  offset += 1
  multiple = (bit_buffer & (1 << 0)) != 0
  requeue = (bit_buffer & (1 << 1)) != 0
  self.new(delivery_tag, multiple, requeue)
end

.encode(channel, delivery_tag, multiple, requeue) ⇒ Object

u’delivery_tag = false’, u’multiple = false’, u’requeue = true’

Returns:



2168
2169
2170
2171
2172
2173
2174
2175
2176
# File 'lib/amq/protocol/client.rb', line 2168

def self.encode(channel, delivery_tag, multiple, requeue)
  buffer = @packed_indexes.dup
  buffer << AMQ::Pack.pack_uint64_big_endian(delivery_tag)
  bit_buffer = 0
  bit_buffer = bit_buffer | (1 << 0) if multiple
  bit_buffer = bit_buffer | (1 << 1) if requeue
  buffer << [bit_buffer].pack(PACK_CHAR)
  MethodFrame.new(buffer, channel)
end

.has_content?Boolean

Returns:

  • (Boolean)


2162
2163
2164
# File 'lib/amq/protocol/client.rb', line 2162

def self.has_content?
  false
end