Morton Goldberg
12/2/2007 12:35:00 PM
On Dec 2, 2007, at 12:20 AM, Pokkai Dokkai wrote:
> Gavin Kistner wrote:
>> On Dec 1, 4:41 am, Pokkai Dokkai <bad_good_l...@yahoo.com> wrote:
>> Slim2:~ phrogz$ ri private
>
> hey please understand my question correctly
> that is ,
> change public definition(public method) to private definition(private
> method) by
> using some ideas....
>
> i want like this (ofcourse below is wrong)
> -------------------------------------------------
> class Cls1
> def view
> puts "from view"
> end
> def self.pp
> alias :private view :public view
> end
> end
> c1=3DCls1.new
> c1.view ----->from view
> Cls1.pp
> c1.view ----->undefined method `view' for #<Cls1:0xb7daa8b0>
> (NoMethodError)
I don't believe you can do what I think you want with 'alias'. Maybe =20
the following will work for you.
<code>
class Cls1
def view
puts "from view"
end
end
c1 =3D Cls1.new
c1.view
class Cls1
private :view
end
c1.view
</code>
<result>
from view
NoMethodError: private method =91view=92 called for #<Cls1:0x80e10at top =
=20
level
in untitled document at line 14
</result>
Regards, Morton=