Classes, prototypes, Ruby 1.9.x

31 views
Skip to first unread message

Philipp Kempgen

unread,
Aug 7, 2010, 4:22:32 AM8/7/10
to Johnson talk
Hi,

Do you happen to have an example of how to define a class (or
rather a function/prototype) in JavaScript (e.g. Ruby.Person
or whatever) _and_ use that as a class in Ruby?


As a side note: There was an example in the RubyConf talk (2008)
about adding a method to a Ruby class from JavaScript context
like this:

js> Ruby.String.prototype.embiggen = function() { return this.toUpperCase() }

but "Ruby.String.prototype is undefined".

js> Ruby.String.prototype
=> nil


Ruby version is 1.9.1-p429,

./bin/johnson -v
2.0.0.pre3
I thought I had switched to the "1.9.1" branch before building the
gem but now I'm not so sure as the version does not reflect this,
i.e. it is the same version string as if it was built from the master
branch.


Pretty cool project BTW!


Best regards,
Philipp

--
perl -e 'for($e=14;--$e>-14;) {for($b=-2;$b<1;$b+=.04)
{$r=$n=0;for($h=77;--$h>32&&$r**2+$n**2<4;){$r=($d=$r)
**2-$n**2+$b;$n=2*$d*$n+$e/13}print chr $h}print"\n"}'

Philipp Kempgen

unread,
Aug 12, 2010, 1:22:14 PM8/12/10
to Johnson talk
My message didn't make it to the mailing list after 5 days.
Am I still in the moderation queue?


-------- Original-Nachricht --------
Subject: Classes, prototypes, Ruby 1.9.x
Date: Sat, 07 Aug 2010 10:22:32 +0200
From: Philipp Kempgen <li...@kempgen.net>
To: Johnson talk <johnso...@googlegroups.com>

Steven Parkes

unread,
Aug 19, 2010, 2:53:59 PM8/19/10
to johnso...@googlegroups.com
> Ruby version is 1.9.1-p429,

At last test, Johnson isn't happy with any 1.9 branch. Threads and the JS GC don't work well together.

Reply all
Reply to author
Forward
0 new messages