From: Robert Klemme Date: 2009-07-10T14:40:07+09:00 Subject: Re: a inherent class, how to write? On 10.07.2009 04:01, Zhenning Guan wrote: > I have a file like this; > > class File > class << self > def diff > #some stuff-------------- > end > end > end > > def method_1 > #----------- > end > > def method_2 > #------------ > end > > > method_1 > method_2 > ------------------------------------ > now ,I need to rewrite this file. > > but I don't how to deal with the class File.... > > one. > +++++++++++++++++++ > class File > class << self > def diff > #some stuff-------------- > end > end > end > > class Myclass > def method_1 > end > > def method_2 > end > end > > ++++++++++++++++++++ > > two > ++++++++++++++++++++ > class Myclass > class File > class << self > def diff > #some stuff-------------- > end > end > end > > def method_1 > end > > def method_2 > end > end > +++++++++++++++++++++ That's difficult to answer since we cannot see how your method_1 and method_2 use class File. In the general case inheritance is done like this: class A end class B < A end B is now subclass of A. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/