Class: Vips::Object

Inherits:
GObject::GObject show all
Defined in:
lib/vips/object.rb

Direct Known Subclasses

Image, Interpolate, Operation

Defined Under Namespace

Modules: ObjectLayout Classes: ManagedStruct, Struct

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from GObject::GObject

ffi_managed_struct, #ffi_managed_struct, #ffi_struct, ffi_struct, #initialize

Constructor Details

This class inherits a constructor from GObject::GObject

Class Method Details

print all active VipsObjects, with their reference counts. Handy for debugging ruby-vips.



77
78
79
80
# File 'lib/vips/object.rb', line 77

def self.print_all
    GC.start
    Vips::vips_object_print_all
end

Instance Method Details

#get(name) ⇒ Object



127
128
129
130
131
132
133
134
135
136
137
# File 'lib/vips/object.rb', line 127

def get name
    gtype = get_typeof_property name
    gvalue = GObject::GValue.alloc 
    gvalue.init gtype
    GObject::g_object_get_property self, name, gvalue
    result = gvalue.get

    GLib::logger.debug("Vips::Object.get") {"#{name} == #{result}"}

    return result
end

#get_typeof(name) ⇒ Object



123
124
125
# File 'lib/vips/object.rb', line 123

def get_typeof name
    get_typeof_property name 
end

#get_typeof_property(name) ⇒ Object



111
112
113
114
115
116
117
118
119
120
121
# File 'lib/vips/object.rb', line 111

def get_typeof_property name
    pspec = GObject::GParamSpecPtr.new
    argument_class = Vips::ArgumentClassPtr.new
    argument_instance = Vips::ArgumentInstancePtr.new

    result = Vips::vips_object_get_argument self, name,
        pspec, argument_class, argument_instance
    return 0 if result != 0 

    pspec[:value][:value_type]
end

#set(name, value) ⇒ Object



139
140
141
142
143
144
145
146
147
# File 'lib/vips/object.rb', line 139

def set name, value
    GLib::logger.debug("Vips::Object.set") {"#{name} = #{value}"}

    gtype = get_typeof_property name
    gvalue = GObject::GValue.alloc 
    gvalue.init gtype
    gvalue.set value
    GObject::g_object_set_property self, name, gvalue
end