class GObjectIntrospection::IConstantInfo

Wraps a GIConstantInfo struct; represents a constant.

Constants

TYPE_TAG_TO_UNION_MEMBER

Public Instance Methods

constant_type() click to toggle source
# File lib/ffi-gobject_introspection/i_constant_info.rb, line 31
def constant_type
  @constant_type ||= ITypeInfo.wrap Lib.g_constant_info_get_type self
end
value() click to toggle source
# File lib/ffi-gobject_introspection/i_constant_info.rb, line 20
def value
  case type_tag
  when :utf8
    raw_value.force_encoding("utf-8")
  when :gboolean
    raw_value.nonzero? ? true : false
  else
    raw_value
  end
end

Private Instance Methods

raw_value() click to toggle source
# File lib/ffi-gobject_introspection/i_constant_info.rb, line 41
def raw_value
  value_union = Lib::GIArgument.new
  Lib.g_constant_info_get_value self, value_union
  value_union[union_member_key]
end
type_tag() click to toggle source
# File lib/ffi-gobject_introspection/i_constant_info.rb, line 37
def type_tag
  @type_tag ||= constant_type.tag
end
union_member_key() click to toggle source
# File lib/ffi-gobject_introspection/i_constant_info.rb, line 47
def union_member_key
  TYPE_TAG_TO_UNION_MEMBER[type_tag]
end