From: "Elf M. Sternberg" Date: 2005-09-29T03:46:43+09:00 Subject: Python to Ruby: Two puzzlements... I'm afraid that I'm coming from Python, a B&D language where I'm used to everything be spelled out cleanly, and although I programmed in Perl for many years that was also many years ago. Ruby is baffling the heck out of me. I've been looking at two examples, and I was wondering if someone could explain to me what the Hell is going on. The first is from http://redhanded.hobix.com/bits/hyperextended.html, and my question is about the 'extend' keyword there. Where does that came from? In what object is it defined? It's just hanging there in space. In the same breath, what does the 'super' keyword do in the append_features() method, and why does it need a 'self' in front of it? I've tried reading ruby-docs without finding much illumination. module Mix def inst_meth puts 'inst_meth' end module ClassMethods def class_meth puts 'class_meth' end end extend ClassMethods def self.append_features(klass) super klass.extend(ClassMethods) end end Second, I've seen the following constructions: validates :url :with => %r{^http:.+\.(gif|jpg|png)$}i and check_associations %w(friends downloads links) I'm guessing that the "%r" and "%w" are the ruby equivalents of perl's qr{} and qw{} constructs (does this mean there's a %qq() and %qx() as well?), but I can't find documentation to that effect inside the references available on-line. (And before someone says "Buy the Pickaxe!" I'll just say that I spent my book budget this month on the Rails book and any other purchases will have to wait until my next paycheck.) Thanks! Elf