# class DBus::Data::Struct

A fixed size, heterogenerous tuple.

(The item count is fixed, not the byte size.)

### Public Class Methods

alignment() click to toggle source

        # File lib/dbus/data.rb
    628 def self.alignment
    629   8
    630 end

from_items(value, mode:, type:) click to toggle source

@param value [::Array]

        # File lib/dbus/data.rb
    633 def self.from_items(value, mode:, type:)
    634   value.freeze
    635   return value if mode == :plain
    636
    637   new(value, type: type)
    638 end

from_typed(value, type:) click to toggle source

@param value [::Object] (size, each) @param type [Type] @return [Struct]

        # File lib/dbus/data.rb
    643 def self.from_typed(value, type:)
    644   new(value, type: type)
    645 end

new(value, type:) click to toggle source

@param value [Data::Struct,Enumerable] @param type [SingleCompleteType,Type]

Calls superclass method `DBus::Data::Base::new`

        # File lib/dbus/data.rb
    649 def initialize(value, type:)
    650   type = Type::Factory.make_type(type)
    651   self.class.assert_type_matches_class(type)
    652   @type = type
    653
    654   typed_value = case value
    655                 when self.class
    656                   unless value.type == type
    657                     raise ArgumentError,
    658                           "Specified type is #{type.inspect} but value type is #{value.type.inspect}"
    659                   end
    660
    661                   value.exact_value
    662                 else
    663                   member_types = type.members
    664                   unless value.size == member_types.size
    665                     raise ArgumentError, "Specified type has #{member_types.size} members " \
    666                                          "but value has #{value.size} members"
    667                   end
    668
    669                   member_types.zip(value).map do |item_type, item|
    670                     Data.make_typed(item_type, item)
    671                   end
    672                 end
    673   super(typed_value)
    674 end

type_code() click to toggle source

        # File lib/dbus/data.rb
    624 def self.type_code
    625   "r"
    626 end

### Public Instance Methods

==(other) click to toggle source
Calls superclass method `DBus::Data::Base#==`

        # File lib/dbus/data.rb
    676 def ==(other)
    677   case other
    678   when ::Struct
    679     @value.size == other.size &&
    680       @value.zip(other.to_a).all? { |i, other_i| i == other_i }
    681   else
    682     super
    683   end
    684 end