File: constants.rb

package info (click to toggle)
ruby-cairo 1.17.13-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,532 kB
  • sloc: ruby: 11,997; ansic: 10,183; sh: 48; makefile: 4
file content (24 lines) | stat: -rw-r--r-- 907 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
module Cairo
  define_constants = Proc.new do |const_module, prefix, target|
    target ||= self
    const_module.constants.each do |const_name|
      target.const_set([prefix, const_name].compact.join("_"),
                       const_module.const_get(const_name))
    end
  end

  %w(operator antialias fill_rule line_cap line_join font_slant
     font_weight subpixel_order hint_style hint_metrics content
     format extend filter).each do |name|
    module_name = name.split(/_/).collect {|component| component.capitalize}.join
    define_constants.call(const_get(module_name), name.upcase)
  end

  define_constants.call(PathDataType, "PATH")
  define_constants.call(PathDataType, nil, Path)
  define_constants.call(SVGVersion, nil, SVGSurface)
  define_constants.call(SVGVersion, "SVG")
  if const_defined?(:TextClusterFlag)
    define_constants.call(TextClusterFlag, "TEXT_CLUSTER_FLAG")
  end
end