Hei everybody,
I'm kind of new to ruby and, since i come from C#, one of the main
things i'm missing is the .NET "project" way of organizing the codebase.
As you probably know: in .NET you can arrange your code into a project,
then reference that project to have access to everything public inside
it. Example:
<in DotNetProject>
<file Temp.cs>
namespace Temp
{
public class TestClass { }
}
<file TempTwo.cs>
namespace Temp
{
public class TestTwoClass { }
}
then, in another project, you get access to TestClass and TestTwoClass
referencing the DotNetProject and you can simplify the syntax too by
adding 'using' directives on your files like:
using Temp;
public class NewClass
{
public void DoSomething()
{
TestClass ts = new TestClass();
TestTwoClass ts2 = new TestTwoClass();
//the following is still legal and
//it's the syntax you'll have to use
//if you choose not to add the 'using' line
//at the top
Temp.TestClass ts3 = new Temp.TestClass();
Temp.TestTwoClass ts4 = new Temp.TestTwoClass();
}
}
So: is there a way to do something similar in Ruby? Like using a Module,
but splitted on separate files, such as :
<in file1.rb>
Module test
Class testclass
end
end
<in file2.rb>
Module test
Class testtwoclass
end
end
and then
<in file bootstrapper.rb>
require 'test'
...
ts = test::testclass.new
ts2 = test::testtwoclass.new
...
Sorry if this is a lame question but the
add-every-freaking-file-every-freaking-time way isn't just going to work
on a large project and i don't really like having to code every class
belonging to a namespace in the same file like this :
Module test
Class one
end
Class two
end
...
Class n
end
end
Thanks in advance!
···
--
Posted via http://www.ruby-forum.com/.