Module: Kernel
- Defined in:
- lib/ludy/kernel/m.rb,
lib/ludy/kernel/id.rb,
lib/ludy/kernel/tap.rb,
lib/ludy/kernel/ergo.rb,
lib/ludy/kernel/defun.rb,
lib/ludy/kernel/maybe.rb,
lib/ludy/kernel/if_else.rb,
lib/ludy/kernel/deep_copy.rb,
lib/ludy/deprecated/aspect.rb,
lib/ludy/kernel/public_send.rb,
lib/ludy/kernel/singleton_method.rb,
lib/ludy/tasks/preprocess_cpp/debug_hook.rb,
lib/ludy/tasks/preprocess_cpp/attr_builder.rb,
lib/ludy/tasks/preprocess_cpp/header_guard.rb,
lib/ludy/tasks/preprocess_cpp/template_forward_parameters.rb
Instance Method Summary collapse
-
#alias_singleton_method(new_msg, old_msg) ⇒ Object
it simply alias singleton(instance) method.
- #cut(target, &block) ⇒ Object
-
#deep_copy ⇒ Object
common idiom for: Marshal::load(Marshal::dump(self)).
-
#define_singleton_method(msg, &block) ⇒ Object
it would be defined if RUBY_VERSION < ‘1.9.0’, see rdoc in ruby 1.9.
-
#defun(name, *args, &fun) ⇒ Object
you can use defun for overloading(ad-hoc polymorphism), multi-method, pattern matching, and perhaps others?.
-
#else ⇒ Object
another else variant…
-
#ergo ⇒ Object
it simply return self, see NilClass#ergo.
-
#id(a = nil) ⇒ Object
id returns self.
-
#if ⇒ Object
another if variant…
-
#public_send(msg, *args, &block) ⇒ Object
it would be defined if RUBY_VERSION < ‘1.9.0’, see rdoc in ruby 1.9.
-
#tap {|_self| ... } ⇒ Object
it would be defined if RUBY_VERSION < ‘1.9.0’, see rdoc in ruby 1.9.
Instance Method Details
#alias_singleton_method(new_msg, old_msg) ⇒ Object
it simply alias singleton(instance) method
12 13 14 |
# File 'lib/ludy/kernel/singleton_method.rb', line 12 def alias_singleton_method new_msg, old_msg self.class.__send__ :alias_method, new_msg, old_msg end |
#cut(target, &block) ⇒ Object
8 9 10 |
# File 'lib/ludy/deprecated/aspect.rb', line 8 def cut target, &block (class << target; self; end) end |
#deep_copy ⇒ Object
common idiom for:
Marshal::load(Marshal::dump(self))
5 6 7 |
# File 'lib/ludy/kernel/deep_copy.rb', line 5 def deep_copy Marshal::load(Marshal::dump(self)) end |
#define_singleton_method(msg, &block) ⇒ Object
it would be defined if RUBY_VERSION < ‘1.9.0’, see rdoc in ruby 1.9
7 8 9 |
# File 'lib/ludy/kernel/singleton_method.rb', line 7 def define_singleton_method msg, &block self.class.__send__ :define_method, msg, &block end |
#defun(name, *args, &fun) ⇒ Object
you can use defun for overloading(ad-hoc polymorphism), multi-method, pattern matching, and perhaps others?
7 8 9 |
# File 'lib/ludy/kernel/defun.rb', line 7 def defun name, *args, &fun Ludy::MessageDispatcher.create self, name, args, &fun end |
#else ⇒ Object
another else variant…
10 11 12 13 |
# File 'lib/ludy/kernel/if_else.rb', line 10 def else if self && !self.kind_of?(Ludy::Blackhole) then self else yield end end |
#ergo ⇒ Object
it simply return self, see NilClass#ergo
6 7 8 |
# File 'lib/ludy/kernel/ergo.rb', line 6 def ergo self end |
#id(a = nil) ⇒ Object
id returns self
7 |
# File 'lib/ludy/kernel/id.rb', line 7 def id a = nil; a.nil? ? self : a; end |
#if ⇒ Object
another if variant…
6 7 8 |
# File 'lib/ludy/kernel/if_else.rb', line 6 def if (yield if self).ergo end |
#public_send(msg, *args, &block) ⇒ Object
it would be defined if RUBY_VERSION < ‘1.9.0’, see rdoc in ruby 1.9
7 8 9 10 11 12 13 |
# File 'lib/ludy/kernel/public_send.rb', line 7 def public_send msg, *args, &block if self.respond_to? msg self.__send__ msg, *args, &block else self.method_missing msg, *args, &block end end |
#tap {|_self| ... } ⇒ Object
it would be defined if RUBY_VERSION < ‘1.9.0’, see rdoc in ruby 1.9
7 8 9 10 |
# File 'lib/ludy/kernel/tap.rb', line 7 def tap yield self self end |