module DBus::Data
Exact/explicit representation of D-Bus data types:
-
{Boolean}
-
{Byte}, {Int16}, {Int32}, {Int64}, {UInt16}, {UInt32}, {UInt64}
-
{Double}
-
{String}, {ObjectPath}, {Signature}
-
{Array}, {DictEntry}, {Struct}
-
{UnixFD}
-
{Variant}
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:
-
A value is either {Basic} or a {Container}.
-
Basic
values are either {Fixed}-size or {StringLike}.
Constants
- BY_TYPE_CODE
{ “b” =>
Data::Boolean
, “s” =>Data::String
, …}- Format
Format
strings for String#unpack, both little- and big-endian.
Public Class Methods
Given a plain Ruby value and wanting a D-Bus type, construct an appropriate {Data::Base} instance.
@param type [SingleCompleteType,Type] @param value [::Object,Data::Base] a plain value; exact values also allowed @return [Data::Base] @raise TypeError
# 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
Private Instance Methods
Given a plain Ruby value and wanting a D-Bus type, construct an appropriate {Data::Base} instance.
@param type [SingleCompleteType,Type] @param value [::Object,Data::Base] a plain value; exact values also allowed @return [Data::Base] @raise TypeError
# 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