Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Easy code generation in Ruby.
Patrick Li
8/19/2008 3:30:00 PM
Hi,
I know how to dynamically create methods and classes in Ruby, but is
there anyway to save these methods to a file?
eg. I'm looking for something like this:
define_method_in_file("File.rb", :myMethod) do
instance_variable_set(:@a, "myString")
end
to produce:
<File.rb>
def myMethod
@a = "myString"
end
Thanks a lot for answering. I'm hoping there's something easier than
having to mess about with templates.
-Patrick
--
Posted via
http://www.ruby-...
.
2 Answers
Jason Roelofs
8/19/2008 3:39:00 PM
0
On Tue, Aug 19, 2008 at 11:30 AM, Patrick Li <patrickli_2001@hotmail.com> wrote:
> Hi,
> I know how to dynamically create methods and classes in Ruby, but is
> there anyway to save these methods to a file?
>
> eg. I'm looking for something like this:
> define_method_in_file("File.rb", :myMethod) do
> instance_variable_set(:@a, "myString")
> end
>
> to produce:
> <File.rb>
> def myMethod
> @a = "myString"
> end
>
> Thanks a lot for answering. I'm hoping there's something easier than
> having to mess about with templates.
> -Patrick
> --
> Posted via
http://www.ruby-...
.
>
>
You could try ruby2ruby.
http://seattlerb.rubyforge.org/...
Jason
Patrick Li
8/19/2008 4:04:00 PM
0
That's perfect. Thank you.
--
Posted via
http://www.ruby-...
.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Easy code generation in Ruby.
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password