I want to get the constants defined in my scripts, suppose I have two files like this:
script_two.rb
TWO = 'this is 2'
script_one.rb
require_relative 'script_two'
ONE = 'this is 1'
# Check for constants
I want to know how to get the array of constants [ONE, TWO]
(order doesn't matter).
I know that Object.constants
gives an array of current constants but that includes lots of other constants like TRUE
, NIL
, etc.
I thought of keeping the result of that at the beginning and then call it again after requires so I can make the difference. But it's a bit ugly, isn't there another way?