Class: Qpid::Proton::Types::UniformArray

Inherits:
Array
  • Object
show all
Defined in:
lib/types/array.rb

Overview

*Unsettled API* - An array that is converted to/from an AMQP array of uniform element type. A plain ruby ::Array is converted to/from an AMQP list, which can contain mixed type elements. If invalid elements are included, then TypeError will be raised when encoding to AMQP.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Array

#proton_array_header=, #proton_described?, proton_get, #proton_put

Constructor Details

#initialize(type, elements = nil, descriptor = nil) ⇒ UniformArray

Construct a uniform array, which will be converted to an AMQP array. A plain ruby ::Array is converted to/from an AMQP list, containing mixed type elements.

Parameters:

  • type (Type)

    Elements must be convertible to this AMQP type.

  • elements (Enumerator) (defaults to: nil)

    Initial elements for the array

  • descriptor (Object) (defaults to: nil)

    Optional array descriptor

Raises:



50
51
52
53
54
# File 'lib/types/array.rb', line 50

def initialize(type, elements=nil, descriptor=nil)
  @type, @descriptor = type, descriptor
  raise ArgumentError, "no type specified for array" if @type.nil?
  super elements if elements
end

Instance Attribute Details

#descriptorObject (readonly)

Returns Optional descriptor.

Returns:

  • (Object)

    Optional descriptor.



65
66
67
# File 'lib/types/array.rb', line 65

def descriptor
  @descriptor
end

#typeType (readonly)

Returns Array elements must be convertible to this AMQP type.

Returns:

  • (Type)

    Array elements must be convertible to this AMQP type



62
63
64
# File 'lib/types/array.rb', line 62

def type
  @type
end

Instance Method Details

#<=>(x) ⇒ Object



69
70
71
72
# File 'lib/types/array.rb', line 69

def <=>(x)
  ret = [@type, @descriptor] <=> [x.type, x.descriptor]
  ret == 0 ? super : ret
end

#inspectObject



67
# File 'lib/types/array.rb', line 67

def inspect() "#{self.class.name}<#{type}>#{super}"; end

#proton_array_headerObject

Deprecated.

backwards compatibility Qpid::Proton::Types::UniformArray



57
58
59
# File 'lib/types/array.rb', line 57

def proton_array_header
  @proton_array_header ||= ArrayHeader.new(@type, @descriptor) # Deprecated
end