4 # See `README.markdown`.
10 attr_accessor :initialized
11 alias_method :initialized?, :initialized
15 # This module method is responsible for setting up the entirety of Nfoiled's
16 # overall environment. It will be called before any other Nfoiled
17 # functionality is allowed. In most cases, this will be called for you.
19 # This method also schedules `Nfoiled::finalize` to be automatically run
22 self.initialized = true
23 at_exit { Nfoiled.finalize }
27 # This module method ensures that Nfoiled is initialized. It simply calls
28 # `Nfoiled::initialize!` if Nfoiled hasn't already been initialized.
30 initialize! unless initialized?
34 # This method is responsible for tearing down any environment set up by the
35 # `Ncurses::initialize!` method.
37 self.initialized = false
42 # This module method ensures that Nfoiled is finalize. It simply calls
43 # `Nfoiled::finalize!` if Nfoiled hasn't already been finalized.
45 # TODO: Ensure finalization on fatal errors or interrupts
46 finalize! if initialized?