Class: GObjectIntrospection::IConstantInfo

Inherits:
IBaseInfo
  • Object
show all
Defined in:
lib/ffi-gobject_introspection/i_constant_info.rb

Overview

Wraps a GIConstantInfo struct; represents an constant.

Constant Summary collapse

TYPE_TAG_TO_UNION_MEMBER =
{
  :gint32 => :v_int32,
  :gdouble => :v_double,
  :utf8 => :v_string
}

Instance Method Summary collapse

Methods inherited from IBaseInfo

#==, build_array_method, #container, #deprecated?, #info_type, #initialize, #name, #namespace, #safe_name, #safe_namespace, #to_ptr, wrap

Constructor Details

This class inherits a constructor from GObjectIntrospection::IBaseInfo

Instance Method Details

#constant_typeObject



26
27
28
# File 'lib/ffi-gobject_introspection/i_constant_info.rb', line 26

def constant_type
  ITypeInfo.wrap(Lib.g_constant_info_get_type @gobj)
end

#valueObject



16
17
18
19
20
21
22
23
24
# File 'lib/ffi-gobject_introspection/i_constant_info.rb', line 16

def value
  tag = constant_type.tag
  val = value_union[TYPE_TAG_TO_UNION_MEMBER[tag]]
  if RUBY_VERSION >= "1.9" and tag == :utf8
    val.force_encoding("utf-8")
  else
    val
  end
end

#value_unionObject



10
11
12
13
14
# File 'lib/ffi-gobject_introspection/i_constant_info.rb', line 10

def value_union
  val = Lib::GIArgument.new
  Lib.g_constant_info_get_value @gobj, val
  return val
end