Class: GObjectIntrospection::RegisteredTypeInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/gobject-introspection/registered-type-info.rb

Instance Method Summary collapse

Instance Method Details

#descriptionObject



45
46
47
# File 'lib/gobject-introspection/registered-type-info.rb', line 45

def description
  "#{gtype.to_class}(#{gtype.name})"
end

#try_convert(value) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/gobject-introspection/registered-type-info.rb', line 19

def try_convert(value)
  return nil if value.nil?

  type = gtype
  if type == GLib::Type::NONE
    ns = namespace
    return value unless Object.const_defined?(ns)
    mod = Object.const_get(ns)
    return value unless mod.const_defined?(name)
    klass = mod.const_get(name)
  else
    klass = type.to_class
  end

  case value
  when klass
    value
  else
    if klass.respond_to?(:try_convert)
      klass.try_convert(value)
    else
      nil
    end
  end
end