From: Bazsl Date: 2007-10-22T00:38:41+09:00 Subject: Re: Can class methods be in a module? 7stud -- wrote: > Bazsl wrote: > >> Is it possible to put a class method in a module, for example: >> >> module FtpClientMod >> def self.do_send(file_template, show_progress) >> >> and include it in a class as follows? >> >> require 'ftpclientmod' >> >> class FtpClient >> include FtpClientMod >> >> When I try this I get an error that the method cannot be found. >> > > Maybe this will work for you: > > > module MyMethods > def greet > puts "hello" > end > end > > > class Dog > include MyMethods > extend MyMethods > end > > Dog.greet #hello > > That works but the method in the module does not have access to class variables. Is there any way to give the method in the module access to class variables?