Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

package like java

Im trying aptana radrails framework and im crating a .rb for each script or class.

My problem is how i can link all my files so i can call a class thats in an other script?

See that my problem is wotking with a lot of scripts and that i dont wanto manually add all. In Java you only have to write the package wich pertais the script and its added and linked, in ruby exist something similar?
 
Ryexander":3prgx31m said:
require '<path to file>'

placed at the top of the script will load the script form said file and allow you to used it as if the code was in the same file.

i know, but im talking about other thing. I want to use java style where you only have to set the package of the script(one line), then all scripts with the same package are autolinked and required.

Obiusly is more quick and easy.
 
You could do something like:
Ruby:
module Kernel

  def require_directory(dir = './')

    files = Dir.glob(dir + '*.rb')

    files.each do |i|

      require(i)

    end

  end

end
 
I personally think the list of files is what you actually want, as this way you can include whichever scripts you want and therefore easily disable them by outcommenting. If you include all scripts automatically, you'll have RMVXP's default script library.
 
Zeriab":2oc3dke3 said:
You can use modules to organize classes just like with packages.
Do note that modules is a stronger concept since you can use them for mix-ins.

Personally I would either create an _index.rb or use Neo-Bahamuts snippet with the recursive flag in Dir.glob
There are some examples here: http://corelib.rubyonrails.org/classes/Dir.html

*hugs*

with index.rb are meaning a file that loads and link all or something like that?
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top