⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.116
Server IP:
78.40.11.138
Server:
Linux tango.o2switch.net 4.18.0-553.30.1.lve.el8.x86_64 #1 SMP Tue Dec 3 01:21:19 UTC 2024 x86_64
Server Software:
Apache
PHP Version:
7.4.33
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
opt
/
alt
/
ruby19
/
share
/
ri
/
1.9.1
/
system
/
Module
/
View File Name :
define_method-i.ri
U:RDoc::AnyMethod[iI"define_method:ETI"Module#define_method;FF:privateo:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"=Defines an instance method in the receiver. The _method_;TI"Hparameter can be a +Proc+, a +Method+ or an +UnboundMethod+ object.;TI"GIf a block is specified, it is used as the method body. This block;TI"Cis evaluated using <code>instance_eval</code>, a point that is;TI"Itricky to demonstrate because <code>define_method</code> is private.;TI"@(This is why we resort to the +send+ hack in this example.);To:RDoc::Markup::BlankLine o:RDoc::Markup::Verbatim; [I" class A ;FI" def fred ;FI" puts "In Fred" ;FI" end ;FI"' def create_method(name, &block) ;FI"7 self.class.send(:define_method, name, &block) ;FI" end ;FI"3 define_method(:wilma) { puts "Charge it!" } ;FI" end ;FI"class B < A ;FI"6 define_method(:barney, instance_method(:fred)) ;FI" end ;FI"a = B.new ;FI"a.barney ;FI" a.wilma ;FI"(a.create_method(:betty) { p self } ;FI" a.betty ;Fo; ; [I"<em>produces:</em>;T@o;; [I" In Fred ;FI"Charge it! ;FI"#<B:0x401b39e8>;F: @file0I"`define_method(symbol, method) -> new_method define_method(symbol) { block } -> proc ;T0[ I"(*args);FI"proc.c;T