Wraps n ContentObjects; a baseclass for erf/key encapsulation.
Attributes
| content | [R] | An array of all ContentObjects indexed by this Container. |
Public class methods
Public instance methods
add
(o)
Add a content object giving the ContentObject
[show source]
# File lib/nwn/res.rb, line 85 85: def add o 86: @content << o 87: end
add_file
(filename, io = nil)
Add a content object giving a filename and a optional io.
[show source]
# File lib/nwn/res.rb, line 80 80: def add_file filename, io = nil 81: @content << ContentObject.new_from(filename, io) 82: end
filenames
()
Returns a list of filenames, all lowercase.
[show source]
# File lib/nwn/res.rb, line 90 90: def filenames 91: @content.map {|x| x.filename.downcase } 92: end
get
(filename)
Get the contents of the given filename. Raises ENOENT if not mapped.
[show source]
# File lib/nwn/res.rb, line 107 107: def get filename 108: get_content_object(filename).get 109: 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 96 96: def get_content_object filename 97: filename = filename.downcase 98: ret = @content.select {|x| filename == x.filename } 99: raise Errno::ENOENT, 100: "No ContentObject with the given filename #{filename.inspect} found." if 101: ret.size == 0 102: ret[0] 103: end
has?
(filename)
Returns true if the given filename is contained herein. Case-insensitive.
[show source]
# File lib/nwn/res.rb, line 74 74: def has?(filename) 75: filenames.index(filename.downcase) != nil 76: end