Tcl/tk translate

I am still fairly new to ruby/tk
I am trying to translate some simple programs from tcl/tk to ruby/tk.
The following stumps me however. Could someone help me translate.
Specifically, the foreach {x y} [$w coords $item]. The $w refers to
TkcPolygons.

proc poly'rotate {w item angle} {
    set delta [expr {$angle/180.*acos(-1)}]
    foreach {x y} [$w coords $item] {
        set r [expr {hypot($y,$x)}]
        set a [expr {atan2($y,$x)+$delta}]
        lappend coords [expr {cos($a)*$r}] [expr {sin($a)*$r}]

thank you

Message-ID: <pan.2005.09.14.01.51.35.820289@accesswave.ca>

proc poly'rotate {w item angle} {
    set delta [expr {$angle/180.*acos(-1)}]
    foreach {x y} [$w coords $item] {
        set r [expr {hypot($y,$x)}]
        set a [expr {atan2($y,$x)+$delta}]
        lappend coords [expr {cos($a)*$r}] [expr {sin($a)*$r}]

For example,

···

From: Ed Redman <redman@accesswave.ca>
Subject: tcl/tk translate
Date: Wed, 14 Sep 2005 10:56:33 +0900
---------------------------------------------------------------
require 'tk'
require 'enumerator'

def poly_rotate(citem, angle)
  delta = (angle * Math::PI)/180.0
  citem.coords = citem.coords.enum_slice(2).collect{|x, y|
    r = Math::hypot(y, x)
    a = Math::atan2(y, x) + delta
    [Math::cos(a) * r, Math::sin(a) * r]
  }
end

coords = [[100, 30], [200, 30], [100, 80]]

c = TkCanvas.new(:height=>480, :width=>480,
                 :scrollregion=>[-240, -240, 240, 240]).pack
poly = TkcPolygon.new(c, coords, :fill=>'red')
p poly.coords

TkcOval.new(c, [[-2, -2], [2, 2]], :fill=>'black')

TkTimer.start(20, -1, proc{poly_rotate(poly, 5)})

Tk.mainloop
---------------------------------------------------------------
--
Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)

Hidetoshi NAGAI wrote:

TkTimer.start(20, -1, proc{poly_rotate(poly, 5)})

When I pasted your sample code into a text file and ran it on my
One-Click Windows install of Ruby 1.8.2 I received the following error
message:

undefined method `start' for TkTimer:Class (NoMethodError)

Then when I tried creating a new instance of a TkTimer class object and
use the start method like this:

timer=TkTimer.new
timer.start(20, -1, proc{poly_rotate(poly, 5)})

I received an error stating Argument '-1' need to be Proc
(ArgumentError).

Just curious if this might be due to the version of Tk that's bundled
with my Ruby distro...

Message-ID: <1126707672.471776.7640@g47g2000cwa.googlegroups.com>

> TkTimer.start(20, -1, proc{poly_rotate(poly, 5)})
When I pasted your sample code into a text file and ran it on my
One-Click Windows install of Ruby 1.8.2 I received the following error
message:
undefined method `start' for TkTimer:Class (NoMethodError)

Hmmm... I commited TkTimer.start at 2004/10/15.
Ruby 1.8.2 must have the method.

TkTimer.start is TkTimer.new + TkTimer#start.
So, instead of TkTimer.start, you can write:

  TkTimer.new(20, -1, proc{poly_rotate(poly, 5)}).start

···

From: "gregarican" <greg.kujawa@gmail.com>
Subject: Re: tcl/tk translate
Date: Wed, 14 Sep 2005 23:21:34 +0900

--
Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)

Hidetoshi NAGAI wrote:

Hmmm... I commited TkTimer.start at 2004/10/15.
Ruby 1.8.2 must have the method.

The start method is present, but I think what's being passed along is
wrong. Note the error message I receive when creating a new TkTimer
object and then using the start method:

timer=TkTimer.new
timer.start(20, -1, proc{poly_rotate(poly, 5)})

ArgumentError: Argument '-1' need to be Proc
(ArgumentError).
     from c:/ruby/lib/ruby/1.8/tk/timer.rb:338:in 'start'

Message-ID: <1126806543.751060.97660@g14g2000cwa.googlegroups.com>

The start method is present, but I think what's being passed along is
wrong. Note the error message I receive when creating a new TkTimer
object and then using the start method:

timer=TkTimer.new
timer.start(20, -1, proc{poly_rotate(poly, 5)})

You'll misunderstand about arguments of those methods.
Please read my last mail again.

···

From: "gregarican" <greg.kujawa@gmail.com>
Subject: Re: tcl/tk translate
Date: Fri, 16 Sep 2005 02:51:34 +0900

From: Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
Subject: Re: tcl/tk translate
Date: Thu, 15 Sep 2005 11:31:32 +0900
Message-ID: <20050915.113123.74733442.nagai@ai.kyutech.ac.jp>

TkTimer.start is TkTimer.new + TkTimer#start.
So, instead of TkTimer.start, you can write:

  TkTimer.new(20, -1, proc{poly_rotate(poly, 5)}).start

That is,
-----------------------------------------------------------------
  timer = TkTimer.new(20, -1, proc{poly_rotate(poly, 5)})
  timer.start
-----------------------------------------------------------------
--
Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)

Hidetoshi NAGAI wrote:

You'll misunderstand about arguments of those methods.
Please read my last mail again.

Sorry. I forgot to require enumerable. That's why it bombed. Doooh!