Sha256: afb750bd2373232f779d3f126d09b1f6699dcfdb5b2028551f7ecc2a497c0eec
Contents?: true
Size: 1.58 KB
Versions: 2
Compression:
Stored size: 1.58 KB
Contents
### # wxRuby3 sampler application core extensions # Copyright (c) M.J.N. Corino, The Netherlands ### class ::String def modulize! self.gsub!(/[^a-zA-Z0-9_]/, '_') self.sub!(/^[a-z\d]*/) { $&.capitalize } self.gsub!(/(?:_|(\/))([a-z\d]*)/i) { "#{$1}#{$2.capitalize}" } self end def modulize self.dup.modulize! end end # Hack to make the sample loader modules behave like the normal 'toplevel' binding # otherwise samples using 'include Wx' (or other modules) will fail on referencing # a constant unscoped from one of these included modules class ::Module def const_missing(sym) if self.name.start_with?('WxRuby::Sample::SampleLoader_') && (scope = self.name.split('::')).size > 3 top_mod = Object.const_get(scope[0,3].join('::')) return top_mod.const_get(sym) end begin super rescue NoMethodError raise NameError, "uninitialized constant #{sym}" end end end # Hack to make the sample loader modules behave like the normal 'toplevel' binding # otherwise samples using 'include Wx' (or other modules) will fail on referencing # a (module) method unscoped from one of these included modules module ::Kernel def method_missing(name, *args) if self.class.name.start_with?('WxRuby::Sample::SampleLoader_') && (scope = self.class.name.split('::')).size > 3 top_mod = Object.const_get(scope[0,3].join('::')) return top_mod.__send__(name, *args) if top_mod.respond_to?(name) top_mod.included_modules.each do |imod| return imod.__send__(name, *args) if imod.respond_to?(name) end end super end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
wxruby3-0.9.0.pre.beta.9 | samples/sampler/ext.rb |
wxruby3-0.9.0.pre.beta.8 | samples/sampler/ext.rb |