# class DBus::Data::Array

An `Array`, or a Dictionary (Hash).

### Public Class Methods

alignment() click to toggle source

        # File lib/dbus/data.rb
    555 def self.alignment
    556   4
    557 end

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

TODO: check that Hash keys are basic types @param mode [:plain,:exact] @param type [Type] @param hash [Boolean] are we unmarshalling an ARRAY of DICT_ENTRY @return [Data::Array]

        # File lib/dbus/data.rb
    564 def self.from_items(value, mode:, type:, hash: false)
    565   value = Hash[value] if hash
    566   return value if mode == :plain
    567
    568   new(value, type: type)
    569 end

from_typed(value, type:) click to toggle source

@param value [::Object] @param type [Type] @return [Data::Array]

        # File lib/dbus/data.rb
    574 def self.from_typed(value, type:)
    575   new(value, type: type) # initialize(::Array<Data::Base>)
    576 end

new(value, type:) click to toggle source

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

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

        # File lib/dbus/data.rb
    597 def initialize(value, type:)
    598   type = Type::Factory.make_type(type)
    599   self.class.assert_type_matches_class(type)
    600   @type = type
    601
    602   typed_value = case value
    603                 when Data::Array
    604                   unless value.type == type
    605                     raise ArgumentError,
    606                           "Specified type is #{type.inspect} but value type is #{value.type.inspect}"
    607                   end
    608
    609                   value.exact_value
    610                 else
    611                   # TODO: Dict??
    612                   value.map do |i|
    613                     Data.make_typed(type.child, i)
    614                   end
    615                 end
    616   super(typed_value)
    617 end

type_code() click to toggle source

        # File lib/dbus/data.rb
    551 def self.type_code
    552   "a"
    553 end

### Public Instance Methods

value() click to toggle source
Calls superclass method `DBus::Data::Container#value`

        # File lib/dbus/data.rb
    578 def value
    579   v = super
    580   if type.child.sigtype == Type::DICT_ENTRY
    581     # BTW this makes a copy so mutating it is pointless
    582     v.to_h
    583   else
    584     v
    585   end
    586 end