[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: [ANN] RubyJS - Convert Ruby to Javascript

Michael Neumann

1/16/2007 11:38:00 AM

Une Bévue wrote:

> Michael Neumann <mneumann@ntecs.de> wrote:
>
>> > I got the same error with that writing :
>> > ../bin/../lib/rubyjs/method_generator.rb:1040:in `method_missing': Not
>> > implemented (RuntimeError)
>> > [...]
>> > from ../bin/rubyjs_gen:82
>>
>> Ah, that seems to be a different problem. Can I see your "Ruby/JS" code?
>> You probably use a Ruby construct which is not yet supported ("case" for
>> example).
>
> not at all, as i said, i've just simplified your HelloWorld class but
> add the `document.getEllementById...` and change yours p(something) to
> self.puts(something) here it is :
>
> <http://www.yvon-thoraval.com/ruby2js/ntecs.de/hg-projects/rub...
> essai.rb>

Change #{ ... } to #< ... >

def puts(str)
`document.getElementById("STDOUT")['innerHTML'] =
document.getElementById("STDOUT")['innerHTML'] + "#<str>\n"`
end

And if you move "puts" into module Kernel, then you can also use the "p"
method, which is equivalent to puts(obj.inspect).

Regards,

Michael

1 Answer

unbewusst.sein

1/16/2007 12:17:00 PM

0

Michael Neumann <mneumann@ntecs.de> wrote:

> Change #{ ... } to #< ... >
>
> def puts(str)
> `document.getElementById("STDOUT")['innerHTML'] =
> document.getElementById("STDOUT")['innerHTML'] + "#<str>\n"`
> end
>
> And if you move "puts" into module Kernel, then you can also use the "p"
> method, which is equivalent to puts(obj.inspect).

OK fine, thanks.

first i had a js error at line 609 (unterminated string) of the
resulting file because i get :

document... = document... + "_str
";

instead of having :

document... = document... + _str + "\n";

and, after correcting that point i get from js console :

Error: uncaught exception: [object Object]

my html file being at :

<http://www.yvon-thoraval.com/ruby2js/ntecs.de/hg-projects/rub...
index.html>

Again, vielen dank ;-)

--
Artaban de Médée