class GObjectIntrospection::IBaseInfo

Wraps GIBaseInfo struct, the base type for all info types. Decendant types will be implemented as needed.

Public Class Methods

build_array_method(method, single = nil) click to toggle source

This is a helper method to construct a method returning an array, out of the methods returning their number and the individual elements.

For example, given the methods n_foos and foo(i), this method will create an additional method foos returning all foos.

Provide the second parameter if the plural is not trivially constructed by adding s to the singular.

Examples:

build_array_method :fields
build_array_mehtod :properties, :property
build_array_method :get_methods
# File lib/ffi-gobject_introspection/i_base_info.rb, line 39
def self.build_array_method method, single = nil
  method = method.to_s
  single ||= method.to_s[0..-2]
  count = method.sub(/^(get_)?/, "\\1n_")
  self.class_eval <<-CODE
    def #{method}
      (0..(#{count} - 1)).map do |i|
        #{single} i
      end
    end
  CODE
end
build_finder_method(method, counter = nil, fetcher = nil) click to toggle source

This is a helper method to construct a method for finding an element, out of the methods returning their number and the individual elements.

For example, given the methods n_foos and foo(i), this method will create an additional method find_foo returning the foo with the matching name.

Optionally provide counter and fetcher methods if they cannot be trivially derived from the finder method.

Examples:

build_finder_method :find_field
build_finder_method :find_property, :n_properties
build_finder_method :find_method, :get_n_methods, :get_method
# File lib/ffi-gobject_introspection/i_base_info.rb, line 68
def self.build_finder_method method, counter = nil, fetcher = nil
  method = method.to_s
  single = method.sub(/^find_/, "")
  counter ||= "n_#{single}s"
  fetcher ||= "#{single}"
  self.class_eval <<-CODE
    def #{method}(name)
      (0..(#{counter} - 1)).each do |i|
        it = #{fetcher}(i)
        return it if it.name == name
      end
      nil
    end
  CODE
end
make_finalizer(lib, ptr) click to toggle source
# File lib/ffi-gobject_introspection/i_base_info.rb, line 16
def self.make_finalizer lib, ptr
  proc { lib.g_base_info_unref ptr }
end
new(ptr, lib=Lib) click to toggle source
# File lib/ffi-gobject_introspection/i_base_info.rb, line 5
def initialize ptr, lib=Lib
  raise ArgumentError, "ptr must not be null" if ptr.null?

  unless defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
    ObjectSpace.define_finalizer self, self.class.make_finalizer(lib, ptr)
  end

  @gobj = ptr
  @lib = lib
end
wrap(ptr) click to toggle source
# File lib/ffi-gobject_introspection/i_base_info.rb, line 110
def self.wrap ptr
  return nil if ptr.null?
  return new ptr
end

Public Instance Methods

==(other) click to toggle source
# File lib/ffi-gobject_introspection/i_base_info.rb, line 115
def == other
  Lib.g_base_info_equal @gobj, other.to_ptr
end
container() click to toggle source
# File lib/ffi-gobject_introspection/i_base_info.rb, line 100
def container
  ptr = Lib.g_base_info_get_container @gobj
  Lib.g_base_info_ref ptr
  IRepository.wrap_ibaseinfo_pointer ptr
end
deprecated?() click to toggle source
# File lib/ffi-gobject_introspection/i_base_info.rb, line 106
def deprecated?
  Lib.g_base_info_is_deprecated @gobj
end
info_type() click to toggle source
# File lib/ffi-gobject_introspection/i_base_info.rb, line 88
def info_type
  Lib.g_base_info_get_type @gobj
end
name() click to toggle source
# File lib/ffi-gobject_introspection/i_base_info.rb, line 84
def name
  Lib.g_base_info_get_name @gobj
end
namespace() click to toggle source
# File lib/ffi-gobject_introspection/i_base_info.rb, line 92
def namespace
  Lib.g_base_info_get_namespace @gobj
end
safe_namespace() click to toggle source
# File lib/ffi-gobject_introspection/i_base_info.rb, line 96
def safe_namespace
  namespace.gsub(/^(.)/) { $1.upcase }
end
to_ptr() click to toggle source
# File lib/ffi-gobject_introspection/i_base_info.rb, line 20
def to_ptr
  @gobj
end