# class Fiddle::CUnionEntity

A pointer to a C union

### Public Class Methods

size (types)
Source

    # File ext/fiddle/lib/fiddle/struct.rb, line 542
    def CUnionEntity.size(types)
      types.map { |type, count = 1|
        if type.respond_to?(:entity_class)
          type.size * count
        else
          PackInfo::SIZE_MAP[type] * count
        end
      }.max
    end

Returns the size needed for the union with the given `types`.

    Fiddle::CUnionEntity.size(
      [ Fiddle::TYPE_DOUBLE,
        Fiddle::TYPE_INT,
        Fiddle::TYPE_CHAR,
        Fiddle::TYPE_VOIDP ]) #=> 8

### Public Instance Methods

set_ctypes (types)
Source

    # File ext/fiddle/lib/fiddle/struct.rb, line 554
    def set_ctypes(types)
      @ctypes = types
      @offset = Array.new(types.length, 0)
      @size   = self.class.size types
    end

Calculate the necessary offset and for each union member with the given `types`