class Import_Module::Scope::Source

kk

Attributes

methods[R]
mod[R]

Public Class Methods

enclose(mod) click to toggle source
# File lib/algebra/import-module.rb, line 274
def self.enclose(mod)
  s = self
  mod.instance_eval do
    defined? @__IMPORT_MODULE_PREFIX_source or
       @__IMPORT_MODULE_PREFIX_source = s.new(mod)
  end
end
new(mod) click to toggle source
# File lib/algebra/import-module.rb, line 282
def initialize(mod)
  @mod = mod
  @methods = _methods
  store
end

Public Instance Methods

inspect() click to toggle source
# File lib/algebra/import-module.rb, line 288
def inspect
  "Source(#{@mod})"
end
param(meth) click to toggle source
# File lib/algebra/import-module.rb, line 292
def param(meth)
  s = ""
  if (n = @mod.instance_method(meth).arity) >= 0
    n.times do |i| s << "x#{i}, " end
    s << "&b"
  else
    (-n-1).times do |i| s << "x#{i}, " end
    s << "*a, &b"
  end
end
param0(meth) click to toggle source
# File lib/algebra/import-module.rb, line 303
def param0(meth)
  s = ""
  if (n = @mod.instance_method(meth).arity) >= 0
    n.times do |i| s << "x#{i}, " end
    s << "b"
  else
    (-n-1).times do |i| s << "x#{i}, " end
    s << "a, b"
  end
end

Private Instance Methods

_methods() click to toggle source
# File lib/algebra/import-module.rb, line 316
def _methods
  meths = @mod.instance_methods(true)
  meths.concat @mod.protected_instance_methods(true)
  meths.concat @mod.private_instance_methods(true)
  meths.reject!{|f| f =~ /^__IMPORT_MODULE_PREFIX_/ }
  meths
end
store() click to toggle source
# File lib/algebra/import-module.rb, line 324
def store
  # Store Soruce methods
  methods = @methods
  @mod.module_eval do
    methods.__each__ do |meth|
      meth0 = Import_Module.name(meth, self)
      unless method_defined? meth0
        alias_method meth0, meth
        public meth0 if true
      end
    end
  end
end