module NWN::TwoDA::Cache
This is a simple 2da cache.
Public Class Methods
get(name)
click to toggle source
Get the 2da file with the given name. name
is without extension. This being a cache, modifications to the returned Table
will be reflected in further calls to Cache.get
.
# File lib/nwn/twoda.rb, line 365 def self.get(name) raise Exception, "You need to set up the cache first through the environment variable NWN_LIB_2DA_LOCATION." unless @_roots.size > 0 @_cache[name.downcase] ||= read_2da(name.downcase) end
setup(root_directories)
click to toggle source
Set the file system path spec where all 2da files reside. Call this on application startup. path spec is a colon-separated list of paths, just like $PATH.
# File lib/nwn/twoda.rb, line 357 def self.setup root_directories @_roots = root_directories.split(File::PATH_SEPARATOR). compact.reject {|x| "" == x.strip } end