class DBus::Data::Array
An Array, or a Dictionary (Hash).
Public Class Methods
alignment()
click to toggle source
# File lib/dbus/data.rb, line 554 def self.alignment 4 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, line 563 def self.from_items(value, mode:, type:, hash: false) value = Hash[value] if hash return value if mode == :plain new(value, type: type) end
from_typed(value, type:)
click to toggle source
@param value [::Object] @param type [Type] @return [Data::Array]
# File lib/dbus/data.rb, line 573 def self.from_typed(value, type:) new(value, type: type) # initialize(::Array<Data::Base>) 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, line 596 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
type_code()
click to toggle source
# File lib/dbus/data.rb, line 550 def self.type_code "a" end
Public Instance Methods
value()
click to toggle source
Calls superclass method
DBus::Data::Container#value
# File lib/dbus/data.rb, line 577 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