Module: NWN::TwoDA::Cache

Defined in:
lib/nwn/helpers.rb

Overview

This is a simple 2da cache.

Class Method Summary collapse

Class Method Details

.get(name) ⇒ Object

Get the 2da file with the given name. name is without extension.

Raises:

  • (Exception)


21
22
23
24
# File 'lib/nwn/helpers.rb', line 21

def self.get(name)
  raise Exception, "You need to set up the cache first through Cache.setup." unless @_root
  @_cache[name.downcase] ||= read_2da(name.downcase)
end

.setup(root) ⇒ Object

Set the file system path where all 2da files reside. Call this on application startup.



16
17
18
# File 'lib/nwn/helpers.rb', line 16

def self.setup root
  @_root = root
end