Shannon Fang <xrfang / hotmail.com> writes: > I feel a little frustrated with Ruby's documentation. I like the > companion book "The Pragmatic Programmer". However, it is apparently not > good enough to be a online manual. May be because I'm completely new to > Ruby. I just feel lost. The following is some of my questions. They are > all related to Ruby's syntax. Please note that I am not currently > interested in the logic of the following example, just simply what the > syntax mean. You might want to look at the Window's help-file version of the book: I believe that it is searchable. In the meantime, all these questions (except the last) are answered in the chapter "The Ruby Language). > > 1. In httpmail-0.3/ruby/dav.rb: > > - class Unlock < ::Net::NetPrivate::HTTPRequest > Q: what is the :: before Net mean? Page 214 "Scope of constants and variables" > - define_http_method_interface :PropFind, true, true > Q: what is the : before PropFind mean? From the menu I know that I can > use attr_reader. It seems to me that attr_reader is a special directive. > But from this example, define_http_method_interface seems a method. So I > guess attr_reader is defined as a method in Object? Anyway, what is the > colon before a variable mean? It represents a literal of type symbol (page 207) > 2. In \ruby\lib\ruby\1.6\net\http.rb: > > - class << self > Q: difference between << and < in class definition? It defines a class based on the object 'self', which in a class definition is the class itself (page 233, 243) > - def HTTP.get( addr, path, port = nil ) > Q: difference between HTTP.get and HTTP#get? I vaguely know there are a > notation of class method and instance method, but which is which? and > in a class, can I just say def get(...) without HTTP. ? Its in the notation convention section of the preface: A#b denotes an instance method 'b' of class 'A'. > I have a lot more similar questions. When I read the html help file, > I can not use search to find any information! > > Could anyone please tell me how can I effectively find information about > the GRAMMA of ruby? And please, if you know, explain the above syntax to > me. Thanks a lot!!! I don't think the grammar alone will help you too much. I recommend reading at least chapter 18 (The Ruby Language) all the way through: it should answer most of your questions. Regards Dave