From: Martin DeMello Date: 2006-09-09T18:36:34+09:00 Subject: Re: DRAW 1280, 1024 On 9/9/06, Benjohn Barnes wrote: > > I'm not suggesting that irb needs changing. I'm suggesting that the > design of the graphics API I'm hoping for should be "irb friendly", > which I believe it will be if well designed. Thus, using irb, I > should be able to issue a commands and see the result. I shouldn't > have to create contexts and windows, program up call backs, cache my > drawing commands somewhere ready for a re-paint and string the lot > together. There's no getting around the "have to create contexts and windows" part - base ruby has absolutely no built-in idea of a graphics context. However, you can do this automatically as follows: to the bottom of sketchpad.rb add @sketchpad = Sketchpad.new(640, 480) def line(*args) @sketchpad.line(*args) end (that is, outside the class definition) now 'require sketchpad.rb' will execute the lines, create a @sketchpad object accessible from within irb, and let you call line as a function straight from the prompt. As a final touch, you can automatically require sketchpad.rb from your irbrc. Look also at the Delegator and Forwardable modules for some ways of automating the method wrapping. martin