Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Split script into several files
Peter Meier
9/7/2006 5:30:00 PM
Hi,
I'm a newbie in ruby.
I want to share some classes between different scripts.
Something like a small library.
How can I do this?
Thanks
Peter
2 Answers
Johannes Held
9/7/2006 5:48:00 PM
0
Peter Meier schrieb:
> I want to share some classes between different scripts.
> Something like a small library.
>
> How can I do this?
Put your code into modules and "require" them.
module Kewl #saved in kewl.rb
class Foo
def x
puts "hello"
end
end
end
And then use it:
require 'kewl'
obj = Kewl::Foo.new
obj.x
--
GruÃ?, Johannes
http://www...
http://gallery.he...
Paul Lutus
9/7/2006 6:26:00 PM
0
Peter Meier wrote:
> Hi,
>
> I'm a newbie in ruby.
>
> I want to share some classes between different scripts.
> Something like a small library.
>
> How can I do this?
Let's say you have a bunch of Ruby source files, named "class(n).rb" in the
current directory. Do this:
#!/usr/bin/ruby -w
require 'class1.rb'
require 'class2.rb'
require 'class3.rb'
# write code here
--
Paul Lutus
http://www.ara...
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Split script into several files
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