Class: Vips::Argument
- Inherits:
-
Object
- Object
- Vips::Argument
- Defined in:
- lib/vips/argument.rb
Overview
This class is used internally to convert Ruby values to arguments to libvips operations.
Defined Under Namespace
Classes: ArrayImageConst
Constant Summary collapse
- @@map_goi_to_vips =
map gobject-introspection’s ruby class names to ours
{ "TrueClass" => "Boolean", "Vips::ArrayDouble" => "Array<Double>", "Vips::ArrayInt" => "Array<Integer>", "Vips::ArrayImage" => "Array<Image>", "Vips::ArrayString" => "Array<String>", }
Instance Attribute Summary collapse
-
#blurb ⇒ Object
readonly
Returns the value of attribute blurb.
-
#flags ⇒ Object
readonly
Returns the value of attribute flags.
-
#gtype ⇒ Object
readonly
Returns the value of attribute gtype.
-
#isset ⇒ Object
readonly
Returns the value of attribute isset.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#op ⇒ Object
readonly
Returns the value of attribute op.
-
#priority ⇒ Object
readonly
Returns the value of attribute priority.
-
#prop ⇒ Object
readonly
Returns the value of attribute prop.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #get_value ⇒ Object
-
#initialize(op, name) ⇒ Argument
constructor
A new instance of Argument.
- #set_value(match_image, value) ⇒ Object
Constructor Details
#initialize(op, name) ⇒ Argument
Returns a new instance of Argument.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/vips/argument.rb', line 20 def initialize(op, name) @op = op @name = name.tr '-', '_' @prop = op.gtype.to_class.property name @blurb = @prop.blurb @gtype = prop.value_type @flags = op.get_argument_flags name @priority = op.get_argument_priority @name @isset = op.argument_isset @name type = GLib::Type[gtype.name].to_class.name type = @@map_goi_to_vips[type] if @@map_goi_to_vips.include? type @type = type end |
Instance Attribute Details
#blurb ⇒ Object (readonly)
Returns the value of attribute blurb.
9 10 11 |
# File 'lib/vips/argument.rb', line 9 def blurb @blurb end |
#flags ⇒ Object (readonly)
Returns the value of attribute flags.
8 9 10 |
# File 'lib/vips/argument.rb', line 8 def flags @flags end |
#gtype ⇒ Object (readonly)
Returns the value of attribute gtype.
9 10 11 |
# File 'lib/vips/argument.rb', line 9 def gtype @gtype end |
#isset ⇒ Object (readonly)
Returns the value of attribute isset.
8 9 10 |
# File 'lib/vips/argument.rb', line 8 def isset @isset end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/vips/argument.rb', line 8 def name @name end |
#op ⇒ Object (readonly)
Returns the value of attribute op.
8 9 10 |
# File 'lib/vips/argument.rb', line 8 def op @op end |
#priority ⇒ Object (readonly)
Returns the value of attribute priority.
8 9 10 |
# File 'lib/vips/argument.rb', line 8 def priority @priority end |
#prop ⇒ Object (readonly)
Returns the value of attribute prop.
8 9 10 |
# File 'lib/vips/argument.rb', line 8 def prop @prop end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
9 10 11 |
# File 'lib/vips/argument.rb', line 9 def type @type end |
Instance Method Details
#get_value ⇒ Object
157 158 159 |
# File 'lib/vips/argument.rb', line 157 def get_value Argument::unwrap @op.get_property(@name) end |
#set_value(match_image, value) ⇒ Object
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/vips/argument.rb', line 126 def set_value(match_image, value) # array-ize value = Argument::arrayize gtype, value # blob-ize if gtype.type_is_a? GLib::Type["VipsBlob"] if not value.is_a? Vips::Blob value = Vips::Blob.copy value end end # image-ize if gtype.type_is_a? GLib::Type["VipsImage"] if not value.is_a? Vips::Image value = Argument::imageize match_image, value end end # MODIFY input images need to be copied before assigning them if (flags & :modify) != 0 # don't use .copy(): we want to make a new pipeline with no # reference back to the old stuff ... this way we can free the # previous image earlier new_image = Vips::Image.memory value.write new_image value = new_image end op.set_property @name, value end |