# class DBus::Type::Factory

### Public Class Methods

from_plain_class(klass) click to toggle source

Make a {Type} corresponding to some plain classes:

- String

- Float

- `DBus::ObjectPath`

- `DBus::Signature`, `DBus::SingleCompleteType`

@param klass [Class] @return [Type] (frozen)

        # File lib/dbus/type.rb
    310 def self.from_plain_class(klass)
    311   @signature_type ||= DBus.type(SIGNATURE)
    312   @class_to_type ||= {
    313     DBus::ObjectPath => DBus.type(OBJECT_PATH),
    314     DBus::Signature => @signature_type,
    315     DBus::SingleCompleteType => @signature_type,
    316     String => DBus.type(STRING),
    317     Float => DBus.type(DOUBLE)
    318   }
    319   t = @class_to_type[klass]
    320   raise ArgumentError, "Cannot convert plain class #{klass} to a D-Bus type" if t.nil?
    321
    322   t
    323 end

make_type(type) click to toggle source

@param type [Type,SingleCompleteType,Class] @see `from_plain_class` @return [Type] (frozen)

        # File lib/dbus/type.rb
    289 def self.make_type(type)
    290   case type
    291   when Type
    292     type
    293   when String
    294     DBus.type(type)
    295   when Class
    296     from_plain_class(type)
    297   else
    298     msg = "Expecting DBus::Type, DBus::SingleCompleteType(aka ::String), or Class, got #{type.inspect}"
    299     raise ArgumentError, msg
    300   end
    301 end