Class: Vips::Object

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

Direct Known Subclasses

Image, Interpolate, Operation, Region

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.



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

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

Instance Method Details

#get(name) ⇒ Object



148
149
150
151
152
153
154
155
156
157
158
# File 'lib/vips/object.rb', line 148

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



117
118
119
120
121
122
123
124
125
126
127
# File 'lib/vips/object.rb', line 117

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



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

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:



130
131
132
133
134
135
# File 'lib/vips/object.rb', line 130

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

  pspec[:value][:value_type]
end

#set(name, value) ⇒ Object



160
161
162
163
164
165
166
167
168
# File 'lib/vips/object.rb', line 160

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