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



144
145
146
147
148
149
150
151
152
153
154
# File 'lib/vips/object.rb', line 144

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



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

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



134
135
136
137
138
139
140
141
142
# File 'lib/vips/object.rb', line 134

def get_typeof name
    pspec = get_pspec name
    if not 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:



126
127
128
129
130
131
# File 'lib/vips/object.rb', line 126

def get_typeof_error name
    pspec = get_pspec name
    raise Vips::Error if not pspec

    pspec[:value][:value_type]
end

#set(name, value) ⇒ Object



156
157
158
159
160
161
162
163
164
# File 'lib/vips/object.rb', line 156

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