Class: GObjectIntrospection::IBaseInfo
- Inherits:
-
Object
- Object
- GObjectIntrospection::IBaseInfo
show all
- Defined in:
- lib/ffi-gobject_introspection/i_base_info.rb
Overview
Wraps GIBaseInfo struct, the base type for all info types. Decendant types will be implemented as needed.
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(ptr) ⇒ IBaseInfo
Returns a new instance of IBaseInfo.
5
6
7
|
# File 'lib/ffi-gobject_introspection/i_base_info.rb', line 5
def initialize ptr
@gobj = ptr
end
|
Class Method Details
.build_array_method(method, single = nil) ⇒ Object
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 args.
Provide the second parameter if the plural is not trivially constructed by adding s
to the singular.
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/ffi-gobject_introspection/i_base_info.rb', line 21
def self.build_array_method method, single = nil
method = method.to_s
single ||= method[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
|
.wrap(ptr) ⇒ Object
72
73
74
75
|
# File 'lib/ffi-gobject_introspection/i_base_info.rb', line 72
def self.wrap ptr
return nil if ptr.null?
return new ptr
end
|
Instance Method Details
#==(other) ⇒ Object
77
78
79
|
# File 'lib/ffi-gobject_introspection/i_base_info.rb', line 77
def == other
Lib.g_base_info_equal @gobj, other.to_ptr
end
|
#deprecated? ⇒ Boolean
68
69
70
|
# File 'lib/ffi-gobject_introspection/i_base_info.rb', line 68
def deprecated?
Lib.g_base_info_is_deprecated @gobj
end
|
#info_type ⇒ Object
51
52
53
|
# File 'lib/ffi-gobject_introspection/i_base_info.rb', line 51
def info_type
Lib.g_base_info_get_type @gobj
end
|
#name ⇒ Object
36
37
38
|
# File 'lib/ffi-gobject_introspection/i_base_info.rb', line 36
def name
Lib.g_base_info_get_name @gobj
end
|
#namespace ⇒ Object
55
56
57
|
# File 'lib/ffi-gobject_introspection/i_base_info.rb', line 55
def namespace
Lib.g_base_info_get_namespace @gobj
end
|
#safe_name ⇒ Object
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/ffi-gobject_introspection/i_base_info.rb', line 40
def safe_name
name.gsub(/^./) do |char|
case char
when "_"
"Private___"
else
char.upcase
end
end
end
|
#safe_namespace ⇒ Object
59
60
61
|
# File 'lib/ffi-gobject_introspection/i_base_info.rb', line 59
def safe_namespace
namespace.gsub(/^(.)/) { $1.upcase }
end
|
#to_ptr ⇒ Object
9
10
11
|
# File 'lib/ffi-gobject_introspection/i_base_info.rb', line 9
def to_ptr
@gobj
end
|