Class: DBus::Type::Factory
- Inherits:
-
Object
- Object
- DBus::Type::Factory
- Defined in:
- lib/dbus/type.rb
Direct Known Subclasses
Class Method Summary collapse
-
.from_plain_class(klass) ⇒ Type
Make a Type corresponding to some plain classes: - String - Float - DBus::ObjectPath - DBus::Signature, DBus::SingleCompleteType.
-
.make_type(type) ⇒ Type
(frozen).
Class Method Details
.from_plain_class(klass) ⇒ Type
Make a Type corresponding to some plain classes:
-
String
-
Float
-
DBus::ObjectPath
-
DBus::Signature, DBus::SingleCompleteType
309 310 311 312 313 314 315 316 317 318 319 320 321 322 |
# File 'lib/dbus/type.rb', line 309 def self.from_plain_class(klass) @signature_type ||= DBus.type(SIGNATURE) @class_to_type ||= { DBus::ObjectPath => DBus.type(OBJECT_PATH), DBus::Signature => @signature_type, DBus::SingleCompleteType => @signature_type, String => DBus.type(STRING), Float => DBus.type(DOUBLE) } t = @class_to_type[klass] raise ArgumentError, "Cannot convert plain class #{klass} to a D-Bus type" if t.nil? t end |
.make_type(type) ⇒ Type
Returns (frozen).
288 289 290 291 292 293 294 295 296 297 298 299 300 |
# File 'lib/dbus/type.rb', line 288 def self.make_type(type) case type when Type type when String DBus.type(type) when Class from_plain_class(type) else msg = "Expecting DBus::Type, DBus::SingleCompleteType(aka ::String), or Class, got #{type.inspect}" raise ArgumentError, msg end end |