Class Qpid::Proton::Codec::Data
In: lib/codec/data.rb
Parent: Object

@private wrapper for pn_data_t* Raises TypeError for invalid conversions

Methods

<<   array   array=   binary   binary=   bool   bool=   byte   byte=   char   char=   code   decimal128   decimal128=   decimal32   decimal32=   decimal64   decimal64=   decode   described   described=   double   double=   encode   enter_exit   expect   fill   finalize!   float   float=   from_object   get   get_array   int   int=   list   list=   long   long=   map   map=   new   next_object   null   null=   null?   object   object=   put   short   short=   string   string=   symbol   symbol=   timestamp   timestamp=   to_object   type   ubyte   ubyte=   uint   uint=   ulong   ulong=   ushort   ushort=   uuid   uuid=  

Included Modules

Util::Wrapper

Constants

PROTON_METHOD_PREFIX = "pn_data"   @private

Public Class methods

@private Clear a pn_data_t* and convert a ruby object into it. If x==nil leave it empty.

@overload initialize(capacity)

  @param capacity [Integer] capacity for the new data instance.

@overload instance(impl)

   @param impl [SWIG::pn_data_t*] wrap the C impl pointer.

@private Convert a pn_data_t* containing a single value to a ruby object. @return [Object, nil] The ruby value extracted from impl or nil if impl is empty

Public Instance methods

Add an arbitrary data value using object=, return self

If the current node is binary, returns its value. Otherwise, it returns an empty string ("").

@return [String] The binary string.

@see string

Puts a binary value.

A binary string is encoded as an ASCII 8-bit string value. This is in contranst to other strings, which are treated as UTF-8 encoded.

@param value [String] An arbitrary string value.

@see string=

If the current node is a boolean, then it returns the value. Otherwise, it returns false.

@return [Boolean] The boolean value.

Puts a boolean value.

@param value [Boolean] The boolean value.

If the current node is an byte, returns its value. Otherwise, it returns 0.

@return [Integer] The byte value.

Puts a byte value.

@param value [Integer] The byte value.

If the current node is a character, returns its value. Otherwise, returns 0.

@return [Integer] The character value.

Puts a character value.

@param value [Integer] The character value.

If the current node is a decimal128, returns its value. Otherwise, returns 0.

@return [Integer] The decimal128 value.

Puts a decimal128 value.

@param value [Integer] The decimal128 value.

If the current node is a decimal32, returns its value. Otherwise, returns 0.

@return [Integer] The decimal32 value.

Puts a decimal32 value.

@param value [Integer] The decimal32 value.

If the current node is a decimal64, returns its value. Otherwise, it returns 0.

@return [Integer] The decimal64 value.

Puts a decimal64 value.

@param value [Integer] The decimal64 value.

Decodes the first value from supplied AMQP data and returns the number of bytes consumed.

@param encoded [String] The encoded data.

If the current node is a double, returns its value. Otherwise, returns 0.

@return [Float] The double precision floating point value.

Puts a double value.

@param value [Float] The double precision floating point value.

Returns a representation of the data encoded in AMQP format.

If the current node is a float, returns its value. Otherwise, returns 0.

@return [Float] The floating point value.

Puts a float value.

@param value [Float] The floating point value.

Get the current value as a single object.

@return [Object] The current node‘s object.

@see type_code @see type

If the current node is an integer, returns its value. Otherwise, returns 0.

@return [Integer] The integer value.

Puts an integer value.

Options

  • value - the integer value

If the current node is a long, returns its value. Otherwise, returns 0.

@return [Integer] The long value.

Puts a long value.

@param value [Integer] The long value.

Move forward to the next value and return it

Return nil if vallue is null, raise exception otherwise.

Set the current value to null

Checks if the current node is null.

@return [Boolean] True if the node is null.

Gets the current node, based on how it was encoded.

@return [Object] The current node.

Puts an arbitrary object type.

The Data instance will determine which AMQP type is appropriate and will use that to encode the object.

@param object [Object] The value.

Puts a new value with the given type into the current node.

@param value [Object] The value. @param type_code [Mapping] The value‘s type.

@private

If the current node is a short, returns its value. Otherwise, returns a 0.

@return [Integer] The short value.

Puts a short value.

@param value [Integer] The short value.

If the current node is a string, returns its value. Otherwise, it returns an empty string ("").

@return [String] The UTF-8 encoded string.

@see binary

Puts a UTF-8 encoded string value.

*NOTE:* A nil value is stored as an empty string rather than as a nil.

@param value [String] The UTF-8 encoded string value.

@see binary=

If the current node is a symbol, returns its value. Otherwise, it returns an empty string ("").

@return [Symbol] The symbol value.

Puts a symbolic value.

@param value [String|Symbol] The symbolic string value.

If the current node is a timestamp, returns its value. Otherwise, returns 0.

@return [Integer] The timestamp value.

Puts a timestamp value.

@param value [Integer] The timestamp value.

If the current node is an unsigned byte, returns its value. Otherwise, it returns 0.

@return [Integer] The unsigned byte value.

Puts an unsigned byte value.

@param value [Integer] The unsigned byte value.

If the current node is an unsigned int, returns its value. Otherwise, returns 0.

@return [Integer] The unsigned integer value.

Puts an unsigned integer value.

@param value [Integer] the unsigned integer value

If the current node is an unsigned long, returns its value. Otherwise, returns 0.

@return [Integer] The unsigned long value.

Puts an unsigned long value.

@param value [Integer] The unsigned long value.

If the current node is an unsigned short, returns its value. Otherwise, it returns 0.

@return [Integer] The unsigned short value.

Puts an unsigned short value.

@param value [Integer] The unsigned short value

If the current value is a UUID, returns its value. Otherwise, it returns nil.

@return [String] The string representation of the UUID.

Puts a UUID value.

The UUID is expected to be in the format of a string or else a 128-bit integer value.

@param value [String, Numeric] A string or numeric representation of the UUID.

@example

  # set a uuid value from a string value
  require 'securerandom'
  @impl.uuid = SecureRandom.uuid

  # or
  @impl.uuid = "fd0289a5-8eec-4a08-9283-81d02c9d2fff"

  # set a uuid value from a 128-bit value
  @impl.uuid = 0 # sets to 00000000-0000-0000-0000-000000000000

[Validate]