glib-mkenums.rb
C language enum description generation library like as glib-mkenums tool.
Copyright(C) 2006-2013 Ruby-GNOME2 Project.
This program is licenced under the same license of Ruby-GNOME2.
# File lib/glib2.rb, line 36 def __add_one_arg_setter(klass) # for Instance methods. method_names = klass.instance_methods(false) method_names.each do |method_name| next if /\Aset_/ !~ method_name property_name = $POSTMATCH next if klass.method_defined?("#{property_name}=") next if klass.instance_method(method_name).arity != 1 begin klass.module_eval("def #{property_name}=(val); set_#{property_name}(val); val; end\n") rescue SyntaxError if $DEBUG $stderr.puts "Couldn't create #{klass}\##{property_name}=(v)." end end end # for Class methods/Module functions. if klass.method(:methods).arity == -1 method_names = klass.methods(false) else method_names = klass.methods end singleton_klass = (class << klass; self; end) method_names.each do |method_name| next if /\Aset_/ !~ method_name property_name = $POSTMATCH next if singleton_klass.method_defined?("#{property_name}=") next if klass.method(method_name).arity != 1 begin klass.module_eval("def self.#{property_name}=(val); set_#{property_name}(val); val; end\n") rescue SyntaxError if $DEBUG $stderr.puts "Couldn't create #{klass}.#{property_name}=(v)." end end end end
# File lib/glib2.rb, line 16 def check_binding_version?(major, minor, micro) BINDING_VERSION[0] > major || (BINDING_VERSION[0] == major && BINDING_VERSION[1] > minor) || (BINDING_VERSION[0] == major && BINDING_VERSION[1] == minor && BINDING_VERSION[2] >= micro) end
# File lib/glib2.rb, line 25 def exit_application(exception, status) msg = exception.message || exception.to_s msg = exception.class.to_s if msg == "" backtrace = exception.backtrace $stderr.puts backtrace.shift + ": #{msg}" backtrace.each do |v| $stderr.puts "\t from #{v}" end exit(status) end
# File lib/glib2.rb, line 75 def prepend_environment_path(path) path = Pathname(path) unless path.is_a?(Pathname) if path.exist? environment_name = "PATH" separator = ::File::PATH_SEPARATOR paths = (ENV[environment_name] || '').split(/#{separator}/) dir = path.to_s dir = dir.gsub(/\//, ::File::ALT_SEPARATOR) if ::File::ALT_SEPARATOR unless paths.include?(dir) paths = [dir] + paths ENV[environment_name] = paths.join(separator) end end end