On Wed, Jul 9, 2008 at 11:22 AM, Clement Ow
<clement.ow / asia.bnpparibas.com> wrote:
> I have built my own ruby library where it contains my specific commands
> and methods that I need to perform certain actions and my main script.
>
> In my ruby library I have something like:
> class Test
>  def toDDMMYYYY(sep)
>    strftime("%d#{sep}%m#{sep}%Y")
>  end
> end
>
> And in my main script I have something like:
>
> require 'PersonalRubyLib.rb'
>
> class MainLogic
>  def show_date
>    d = Date.today
>    d.Test.toDDMMYYYY("-")
>  end
> end
>
> But apparently it shows an error:
> undefined method `toDDMMYYYY' for #<Date: 4909313
> ,2299161> (NoMethodError)
>
> Did do wrongly in calling the class methods, maybe I am confused with
> the syntax of calling class methods? Much help is appreciated, thanks!
> --
> Posted via http://www.ruby-forum.com/.
>
>

You did not define a class method, actually there are more ways to
implement what you want.
I will show you three here, it is up to you to decide what fits your needs best

class  << C = Class::new { ... }
    def m; 42 end
end

C.m

class C
   def self.m; 42 end
end

C.m

module M
   def m; 42 end
   module_function :m
end


M.m

HTH
Robert

-- 
http://ruby-smalltalk.blogspot.com/

---
AALST (n.) One who changes his name to be further to the front
D.Adams; The Meaning of LIFF