Class: AMQ::Protocol::Basic::Credit

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(consumer_tag, credit, drain) ⇒ Credit

Returns a new instance of Credit.



2190
2191
2192
2193
2194
# File 'lib/amq/protocol/client.rb', line 2190

def initialize(consumer_tag, credit, drain)
  @consumer_tag = consumer_tag
  @credit = credit
  @drain = drain
end

Instance Attribute Details

#consumer_tagObject (readonly)

Returns the value of attribute consumer_tag.



2189
2190
2191
# File 'lib/amq/protocol/client.rb', line 2189

def consumer_tag
  @consumer_tag
end

#creditObject (readonly)

Returns the value of attribute credit.



2189
2190
2191
# File 'lib/amq/protocol/client.rb', line 2189

def credit
  @credit
end

#drainObject (readonly)

Returns the value of attribute drain.



2189
2190
2191
# File 'lib/amq/protocol/client.rb', line 2189

def drain
  @drain
end

Class Method Details

.decode(data) ⇒ Object

Returns:



2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
# File 'lib/amq/protocol/client.rb', line 2175

def self.decode(data)
  offset = 0
  length = data[offset, 1].unpack(PACK_CHAR).first
  offset += 1
  consumer_tag = data[offset, length]
  offset += length
  credit = data[offset, 4].unpack(PACK_UINT32).first
  offset += 4
  bit_buffer = data[offset, 1].unpack(PACK_CHAR).first
  offset += 1
  drain = (bit_buffer & (1 << 0)) != 0
  self.new(consumer_tag, credit, drain)
end

.encode(channel, consumer_tag, credit, drain) ⇒ Object

u’consumer_tag = EMPTY_STRING’, u’credit = nil’, u’drain = nil’

Returns:



2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
# File 'lib/amq/protocol/client.rb', line 2202

def self.encode(channel, consumer_tag, credit, drain)
  buffer = ''
  buffer << @packed_indexes
  buffer << consumer_tag.to_s.bytesize.chr
  buffer << consumer_tag.to_s
  buffer << [credit].pack(PACK_UINT32)
  bit_buffer = 0
  bit_buffer = bit_buffer | (1 << 0) if drain
  buffer << [bit_buffer].pack(PACK_CHAR)
  MethodFrame.new(buffer, channel)
end

.has_content?Boolean

Returns:

  • (Boolean)


2196
2197
2198
# File 'lib/amq/protocol/client.rb', line 2196

def self.has_content?
  false
end