Method: Vips::Yard.generate

Defined in:
lib/vips/image.rb

.generateObject

[View source]

1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
# File 'lib/vips/image.rb', line 1746

def self.generate
  alias_gtypes = {}
  ALIAS.each do |name|
    gtype = Vips.type_find "VipsOperation", name
    alias_gtypes[gtype] = name
  end

  generate_class = lambda do |gtype, _|
    name = if alias_gtypes.key? gtype
      alias_gtypes[gtype]
    else
      Vips.nickname_find gtype
    end

    if name
      begin
        # can fail for abstract types
        introspect = Vips::Introspect.get_yard name
      rescue Vips::Error
        nil
      end

      generate_operation(introspect) if introspect
    end

    Vips.vips_type_map gtype, generate_class, nil
  end

  puts "module Vips"
  puts "  class Image"
  puts ""

  generate_class.call(GObject.g_type_from_name("VipsOperation"), nil)

  puts "  end"
  puts "end"
end