aris
1
Hey guys
This may be a very beginner’s question, but I just don’t get it. This
works:
module MyModule
class MyClass
def file_colon_line(*arg)
MyModule::MyClass::textmate_colon_line(old_file_colon_line)
end
def self.textmate_colon_line(file_colon_line)
# ...
end
end
end
But I’d rather just use self when calling text_mate_colon_line like
this:
self::textmate_colon_line(old_file_colon_line)
But this doesn’t work (method not found). What’s the right way to do it?
Thanks,
Josh
josh
2
On Mon, 9 Jul 2012 00:28:41 +0900
Joshua M. [email protected] wrote:
# ...
But this doesn’t work (method not found). What’s the right way to do
it?
self
always points current scope. so, to call class method from the
instance method, use self.class.method_name
:
module MyModule
class MyClass
def file_colon_line(*arg)
self.class.textmate_colon_line(old_file_colon_line)
end
def self.textmate_colon_line(file_colon_line)
# ...
end
end
end
–
Sincerely yours,
Aleksey V. Zapparov A.K.A. ixti
FSF Member #7118
Mobile Phone: +34 677 990 688
Homepage: http://www.ixti.net
JID: [email protected]
*Origin: Happy Hacking!