class DBus::Data::Array
An Array
, or a Dictionary (Hash).
Public Class Methods
Source
# File lib/dbus/data.rb, line 564 def self.from_items(value, mode:, type:, hash: false) value = Hash[value] if hash return value if mode == :plain new(value, type: type) end
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]
Source
# File lib/dbus/data.rb, line 574 def self.from_typed(value, type:) new(value, type: type) # initialize(::Array<Data::Base>) end
@param value [::Object] @param type [Type] @return [Data::Array]
Source
# File lib/dbus/data.rb, line 597 def initialize(value, type:) type = Type::Factory.make_type(type) self.class.assert_type_matches_class(type) @type = type typed_value = case value when Data::Array unless value.type == type raise ArgumentError, "Specified type is #{type.inspect} but value type is #{value.type.inspect}" end value.exact_value else # TODO: Dict?? value.map do |i| Data.make_typed(type.child, i) end end super(typed_value) end
@param value [Data::Array,Enumerable] @param type [SingleCompleteType,Type]
Calls superclass method
DBus::Data::Base::new
Public Instance Methods
Source
# File lib/dbus/data.rb, line 578 def value v = super if type.child.sigtype == Type::DICT_ENTRY # BTW this makes a copy so mutating it is pointless v.to_h else v end end
Calls superclass method
DBus::Data::Container#value