Class: AMQ::Protocol::Connection::Close

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(reply_code, reply_text, class_id, method_id) ⇒ Close

Returns a new instance of Close.



458
459
460
461
462
463
# File 'lib/amq/protocol/client.rb', line 458

def initialize(reply_code, reply_text, class_id, method_id)
  @reply_code = reply_code
  @reply_text = reply_text
  @class_id = class_id
  @method_id = method_id
end

Instance Attribute Details

#class_idObject (readonly)

Returns the value of attribute class_id.



457
458
459
# File 'lib/amq/protocol/client.rb', line 457

def class_id
  @class_id
end

#method_idObject (readonly)

Returns the value of attribute method_id.



457
458
459
# File 'lib/amq/protocol/client.rb', line 457

def method_id
  @method_id
end

#reply_codeObject (readonly)

Returns the value of attribute reply_code.



457
458
459
# File 'lib/amq/protocol/client.rb', line 457

def reply_code
  @reply_code
end

#reply_textObject (readonly)

Returns the value of attribute reply_text.



457
458
459
# File 'lib/amq/protocol/client.rb', line 457

def reply_text
  @reply_text
end

Class Method Details

.decode(data) ⇒ Object

Returns:



442
443
444
445
446
447
448
449
450
451
452
453
454
455
# File 'lib/amq/protocol/client.rb', line 442

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
  reply_code = data[offset, 2].unpack(PACK_UINT16).first
  offset += 2
  length = data[offset, 1].unpack(PACK_CHAR).first
  offset += 1
  reply_text = data[offset, length]
  offset += length
  class_id = data[offset, 2].unpack(PACK_UINT16).first
  offset += 2
  method_id = data[offset, 2].unpack(PACK_UINT16).first
  offset += 2
  self.new(reply_code, reply_text, class_id, method_id)
end

.encode(reply_code, reply_text, class_id, method_id) ⇒ Object

u’reply_code = nil’, u’reply_text = EMPTY_STRING’, u’class_id = nil’, u’method_id = nil’

Returns:



471
472
473
474
475
476
477
478
479
480
# File 'lib/amq/protocol/client.rb', line 471

def self.encode(reply_code, reply_text, class_id, method_id)
  channel = 0
  buffer = @packed_indexes.dup
  buffer << [reply_code].pack(PACK_UINT16)
  buffer << reply_text.to_s.bytesize.chr
  buffer << reply_text.to_s
  buffer << [class_id].pack(PACK_UINT16)
  buffer << [method_id].pack(PACK_UINT16)
  MethodFrame.new(buffer, channel)
end

.has_content?Boolean

Returns:

  • (Boolean)


465
466
467
# File 'lib/amq/protocol/client.rb', line 465

def self.has_content?
  false
end