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.



84
85
86
87
# File 'lib/vips/object.rb', line 84

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

Instance Method Details

#get(name) ⇒ Object



151
152
153
154
155
156
157
158
159
160
161
# File 'lib/vips/object.rb', line 151

def get name
    gtype = get_typeof_error 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_pspec(name) ⇒ Object

return a pspec, or nil ... nil wil leave a message in the error log which you must clear



120
121
122
123
124
125
126
127
128
129
130
# File 'lib/vips/object.rb', line 120

def get_pspec 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 nil if result != 0 

    pspec
end

#get_typeof(name) ⇒ Object

return a gtype, 0 on not found



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

def get_typeof name
    pspec = get_pspec name
    unless pspec
        Vips::vips_error_clear 
        return 0
    end

    pspec[:value][:value_type]
end

#get_typeof_error(name) ⇒ Object

return a gtype, raise an error on not found

Raises:



133
134
135
136
137
138
# File 'lib/vips/object.rb', line 133

def get_typeof_error name
    pspec = get_pspec name
    raise Vips::Error unless pspec

    pspec[:value][:value_type]
end

#set(name, value) ⇒ Object



163
164
165
166
167
168
169
170
171
# File 'lib/vips/object.rb', line 163

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

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