From: Rajinder Yadav Date: 2009-12-14T18:19:31+09:00 Subject: Re: about object methods Ruby Newbee wrote: > Hello, > > I have two questions, > > 1. what's the difference between class method and module method? a class method well belongs to the class =P there can only be one class method, you don't need to create an object(instance) to call a class method a module method is a way to package methods using namespacing, a module is not a like a class, you can create instance of a class but not a module more on modules: http://www.ruby-doc.org/docs/ProgrammingRuby/ > 2. when I say: Dir.pwd, is this a class method or a module method? How > to know if Dir is a module or a class? > use ri to display class information, it clearly states 'pwd' is a class method, type 'ri Dir' at the prompt, type 'ri' alone to find out how to use it yadav@KubuntuX64:$ ri Dir ------------------------------------------------------------- Class: Dir Objects of class +Dir+ are directory streams representing directories in the underlying file system. They provide a variety of ways to list directories and their contents. See also +File+. ..... ..... (edit) ...... ...... Class methods: -------------- [], chdir, chroot, delete, entries, foreach, getwd, glob, mkdir, mktmpdir, new, open, pwd, rmdir, tmpdir, unlink > > Thanks. > > -- Kind Regards, Rajinder Yadav http://DevMentor.org Do Good! - Share Freely