class NWN::Resources::Manager

The resource manager, providing ordered access to Container objects.

Public Class Methods

new() click to toggle source
# File lib/nwn/res.rb, line 148
def initialize
  @path = []
  @_content_cache = nil
end

Public Instance Methods

add_container(c) click to toggle source
# File lib/nwn/res.rb, line 153
def add_container c
  @path << c
end
content() click to toggle source

Get a list of filenames contained inside.

# File lib/nwn/res.rb, line 174
def content
  @_content_cache ||= @path.inject([]) {|a, x|
    a |= x.filenames
  }
end
get(filename) click to toggle source

Get the contents of the given filename. Raises ENOENT if not mapped.

# File lib/nwn/res.rb, line 169
def get filename
  get_content_object(filename).get
end
get_content_object(filename) click to toggle source

Get the ContentObject pointing to the given filename. Raises ENOENT if not mapped.

# File lib/nwn/res.rb, line 159
def get_content_object filename
  @path.reverse.each {|con|
    con.has?(filename) or next
    return con.get_content_object(filename)
  }
  raise Errno::ENOENT, "No ContentObject with the given filename #{filename.inspect} found."
end