Class: DBus::Data::Array
Overview
An Array, or a Dictionary (Hash).
Instance Attribute Summary
Attributes inherited from Container
Class Method Summary collapse
- .alignment ⇒ Object
-
.from_items(value, mode:, type:, hash: false) ⇒ Data::Array
TODO: check that Hash keys are basic types.
- .from_typed(value, type:) ⇒ Data::Array
- .type_code ⇒ Object
Instance Method Summary collapse
-
#initialize(value, type:) ⇒ Array
constructor
A new instance of Array.
- #value ⇒ Object
Methods inherited from Container
basic?, #eql?, #exact_value, fixed?
Methods inherited from Base
#==, assert_type_matches_class, basic?, #eql?, fixed?, #type
Constructor Details
#initialize(value, type:) ⇒ Array
Returns a new instance of Array.
597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 |
# 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 |
Class Method Details
.alignment ⇒ Object
555 556 557 |
# File 'lib/dbus/data.rb', line 555 def self.alignment 4 end |
.from_items(value, mode:, type:, hash: false) ⇒ Data::Array
TODO: check that Hash keys are basic types
564 565 566 567 568 569 |
# 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 |
.from_typed(value, type:) ⇒ Data::Array
574 575 576 |
# File 'lib/dbus/data.rb', line 574 def self.from_typed(value, type:) new(value, type: type) # initialize(::Array<Data::Base>) end |
.type_code ⇒ Object
551 552 553 |
# File 'lib/dbus/data.rb', line 551 def self.type_code "a" end |