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

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
55
# File 'lib/types/array.rb', line 50

def initialize(type, elements=nil, descriptor=nil)
  @type, @descriptor = type, descriptor
  @proton_array_header = nil
  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.



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

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



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

def type
  @type
end

Instance Method Details

#<=>(x)



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

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

#inspect



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

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

#proton_array_header

Deprecated.

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



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

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