• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • Frits Walraven
  • Himai Minh

Ruby Question: Problems with IRB & simple Draw app

Ranch Hand
Posts: 511
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
:-) Hello again,

I am a Ruby newbie... I am using the following version on Mac OS X Tiger:

Raven:/Developer/DevResources/Ruby/Draw untz$ ruby --version
ruby 1.8.2 (2004-12-25) [powerpc-darwin8.0]
Raven:/Developer/DevResources/Ruby/Draw untz$ which ruby

I am experiencing several problems....

1. My irb doesn't support tab completion (the same version of Ruby
on WinXP does support tab completion)...

For example:

Raven:/Developer/DevResources/Ruby/Draw untz$ irb
irb(main):001:0> a = "Hello Ruby Group"
=> "Hello Ruby Group"
irb(main):002:0> a.rev

When I click on the tab key right after rev, it doesn't complete it by
printing out the remaining characters belonging to the word 'reverse'.

Is there a way to check and see if this functionality is turned on for irb?

2. How do I use similar functionality in irb to clear the buffer, as one would
do in Unix using "clear" and WinXP, using "cls"?

3. I copied a simple Draw coding sample and when I tried to run it,
I got an error...

The code for Draw.rb:

Raven:/Developer/DevResources/Ruby/Draw untz$ cat Draw.rb
#!/usr/bin/ruby -w

require 'tk'

class Draw

def initialize(parent)
@canvas = TkCanvas.new(parent)
@start_x = @start_y = 0
@canvas.bind("1", lambda {|e| do_press(e.x, e.y)})
@canvas.bind("B1-Motion", lambda {|x, y| do_motion(x,y)}, "%x %y")
@canvas.bind("Button-Release-1", lambda {|x, y| do_release(x,y)}, "%x %y")

def do_press(x,y)
@start_x = x
@start_y = y
@current_line = TkcLine.new(@canvas, x, y, x,y)

def do_motion(x,y)
if @current_line
@current_line.coords @start_x, @start_y, x, y

def do_release(x,y)
if @current_line
@current_line.coords @start_x, @start_y, x, y
@current_line.fill 'black'
@current_line = nil


root = TkRoot.new { title 'Canvas' }

The error message:

Raven:/Developer/DevResources/Ruby/Draw untz$ ./Draw.rb
/usr/lib/ruby/1.8/tk.rb:1496:in `_invoke_without_enc': bad event type or keysym "Release" (RuntimeError)
from /usr/lib/ruby/1.8/tk.rb:1496:in `_ip_invoke_core'
from /usr/lib/ruby/1.8/tk.rb:1532:in `_tk_call_core'
from /usr/lib/ruby/1.8/tk.rb:1560:in `tk_call_without_enc'
from /usr/lib/ruby/1.8/tk.rb:831:in `_bind_core'
from /usr/lib/ruby/1.8/tk.rb:839:in `_bind'
from /usr/lib/ruby/1.8/tk.rb:921:in `bind'
from /usr/lib/ruby/1.8/tk.rb:2139:in `bind'
from ./Draw.rb:13:in `initialize'
from ./Draw.rb:39:in `new'
from ./Draw.rb:39

Many, many thanks!

Because those who mind don't matter and those who matter don't mind - Seuss. Tiny ad:
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic