Sha256: 3888114043bbab5511c4efdc1585537b1e86d7c25b2e7181682b69dbef46c5cd

Contents?: true

Size: 689 Bytes

Versions: 10

Compression:

Stored size: 689 Bytes

Contents

module GObjectIntrospection
  # Wraps a GIConstantInfo struct; represents an constant.
  class IConstantInfo < IBaseInfo
    TYPE_TAG_TO_UNION_MEMBER = {
      :gint32 => :v_int32,
      :gdouble => :v_double,
      :utf8 => :v_string
    }

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

    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

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

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
gir_ffi-0.4.2 lib/ffi-gobject_introspection/i_constant_info.rb
gir_ffi-0.4.1 lib/ffi-gobject_introspection/i_constant_info.rb
gir_ffi-0.4.0 lib/ffi-gobject_introspection/i_constant_info.rb
gir_ffi-0.3.2 lib/ffi-gobject_introspection/i_constant_info.rb
gir_ffi-0.3.1 lib/ffi-gobject_introspection/i_constant_info.rb
gir_ffi-0.3.0 lib/ffi-gobject_introspection/i_constant_info.rb
gir_ffi-0.2.3 lib/ffi-gobject_introspection/i_constant_info.rb
gir_ffi-0.2.2 lib/ffi-gobject_introspection/i_constant_info.rb
gir_ffi-0.2.1 lib/ffi-gobject_introspection/i_constant_info.rb
gir_ffi-0.2.0 lib/ffi-gobject_introspection/i_constant_info.rb