Ruby pass variable between ruby files

I need to use “mode”, to enables user to practice different functionality .
what I think I can do:

  1. Include a temp.rb file, as the user click one of the ‘mode buttons’, write a module into temp.rb.
  2. Through retrieving from temp.rb, trigger specific code option.
    I am sure this is achievable, just a bit concerned if this will be allowed?

PS: As user click ‘mode’, if there is already a module inside temp.rb, it will be cleared, so no space occupying.

Don’t think of files as being different.
Your extension submodule can span more than one file, so just use a module or instance variable.
Or you could have two different “mode” classes, and instantiate the one that matches the “mode” the user wants.