Module: DBus::Data

Defined in:
lib/dbus/data.rb

Overview

Exact/explicit representation of D-Bus data types:

The common base type is Base.

There are other intermediate classes in the inheritance hierarchy, using the names the specification uses, but they are an implementation detail:

Defined Under Namespace

Classes: Array, Base, Basic, Boolean, Byte, Container, DictEntry, Double, Fixed, Format, Int, Int16, Int32, Int64, ObjectPath, Signature, String, StringLike, Struct, UInt16, UInt32, UInt64, UnixFD, Variant

Constant Summary collapse

BY_TYPE_CODE =

{ “b” => Data::Boolean, “s” => Data::String, …}

by_type_code

Class Method Summary collapse

Class Method Details

.make_typed(type, value) ⇒ Data::Base

Given a plain Ruby value and wanting a D-Bus type, construct an appropriate Base instance.

Parameters:

Returns:

Raises:

  • TypeError



41
42
43
44
45
46
47
# File 'lib/dbus/data.rb', line 41

def make_typed(type, value)
  type = DBus.type(type) unless type.is_a?(Type)
  data_class = Data::BY_TYPE_CODE[type.sigtype]
  # not nil because DBus.type validates

  data_class.from_typed(value, type: type)
end