From: John Joyce Date: 2007-08-19T00:04:59+09:00 Subject: Re: 8086 simulator in ruby On Aug 18, 2007, at 9:24 AM, Chris Carter wrote: > On 8/18/07, Phlip wrote: >>>> Think of do-end as a block that iterates 1 time. That's what it is! >> >> Please read my posting history, blogs, Ruby open source, etc. (-; >> >> Robert Klemme wrote: >> >>> Actually it's not the "10" but the "times" because "CPU8086" >>> would be a >>> method. >>> >>> def CPU8086(&b) >> >> The point: I thought a method was forbidden as a constant. Easy to >> write but >> hard to call. >> >> By contrast... >> >> doc = Hpricot(my_html_string) >> >> His Whyness did something to the module to make it take a method call >> directly... >> > > No modules were hacked or harmed. He just defined a method: > > 3 def Hpricot(input = nil, opts = {}, &blk) > 4 Hpricot.parse(input, opts, &blk) > 5 end > > http://code.whytheluckystiff.net/hpricot/browser/trunk/lib/hpricot/ > parse.rb > > -- > Chris Carter > concentrationstudios.com > brynmawrcs.com > Yep, normal stuff. EXCEPT for the capitalization. You can do it, but it goes against usual style. An example: module Unchi def poots(who) puts "#{who} did pooh, poot" end # Poots = poots alias_method :Poots, :poots end include Unchi Poots("JJ")