Class NWN::Resources::Manager

  1. lib/nwn/res.rb
Parent: Object

The resource manager, providing ordered access to Container objects.

Methods

public class

  1. new

public instance

  1. add_container
  2. content
  3. get
  4. get_content_object

Public class methods

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

Public instance methods

add_container (c)
[show source]
# File lib/nwn/res.rb, line 134
      def add_container c
        @path << c
      end
content ()

Get a list of filenames contained inside.

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

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

[show source]
# File lib/nwn/res.rb, line 150
      def get filename
        get_content_object(filename).get
      end
get_content_object (filename)

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

[show source]
# File lib/nwn/res.rb, line 140
      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