From: Harold Hausman Date: 2007-01-27T14:43:20+09:00 Subject: Re: Another Ruby language question On 1/27/07, Neville Franks wrote: > Following from yesterday I have a few more Ruby questions. > > Can someone please explain what 'self' does in the following: > > module Mod1 > def self.a_method > puts 'a' > end > > def b_method > puts 'b' > end > end > > If self isn't specificed I'm unable to call the method. ex. > Mod1::b_method fails. > So in this particular case, 'self' here refers to the Module called Mod1. Your code defines a method (a_method) on the module itself which allows you to call it with the :: syntax. The other method (b_method) is merely a method defined inside the module. In this case the module is acting as a namespace. If you 'include' this module somewhere in your code you'll be adding the b_method to that place (scope?) (disclaimer: I'm still learning ruby myself, so that may not be the best answer ever, but it is how I understand it... And knowing these guys these days I'll be corrected if I'm wrong, mere moments from now.) > > Next. What does '/upload' mean in: > class Upload < R '/upload' > This is from: > http://www.oreillynet.com/ruby/blog/2007/01/the_joy_of_rolling_your_own_wi.html > Right here you're fishing in _why territory (specifically the camping framework) where things are way over my head, someone else will have to help you there. hth, -Harold