The resource manager, providing ordered access to Container objects.
Public class methods
new
()
[show source]
# File lib/nwn/res.rb, line 129 129: def initialize 130: @path = [] 131: @_content_cache = nil 132: end
Public instance methods
add_container
(c)
[show source]
# File lib/nwn/res.rb, line 134 134: def add_container c 135: @path << c 136: end
content
()
Get a list of filenames contained inside.
[show source]
# File lib/nwn/res.rb, line 155 155: def content 156: @_content_cache ||= @path.inject([]) {|a, x| 157: a |= x.filenames 158: } 159: end
get
(filename)
Get the contents of the given filename. Raises ENOENT if not mapped.
[show source]
# File lib/nwn/res.rb, line 150 150: def get filename 151: get_content_object(filename).get 152: 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 140: def get_content_object filename 141: @path.reverse.each {|con| 142: con.has?(filename) or next 143: return con.get_content_object(filename) 144: } 145: raise Errno::ENOENT, "No ContentObject with the given filename #{filename.inspect} found." 146: end