Module | Rubygame::NamedResource::NamedResourceClassMethods |
In: |
lib/rubygame/named_resource.rb
lib/rubygame/named_resource.rb |
Adds class methods when the NamedResource module is included in a class. (Here, we are assuming that the NamedResource module was included in a class called MyClass.)
Retrieves an instance of the class from a per-class resource table (Hash).
If no object has been saved under the given name, invoke autoload to try to load a new instance, store it in the Hash table under this name, and sets the instance‘s @name to this name.
Retrieves an instance of the class from a per-class resource table (Hash).
If no object has been saved under the given name, invoke autoload to try to load a new instance, store it in the Hash table under this name, and sets the instance‘s @name to this name.
Stores an instance of the class in a per-class resource table (Hash) for future access. If another object is already stored with this name, the old record is lost.
May raise: TypeError, if you try to store anything
that is not kind of this class.
Stores an instance of the class in a per-class resource table (Hash) for future access. If another object is already stored with this name, the old record is lost.
May raise: TypeError, if you try to store anything
that is not kind of this class.
This method is invoked when a non-existing resource is accessed with #[]. By default, this method simply returns nil, effectively disabling autoloading.
You should override this method in your class to provide class-specific loading behavior, or leave it as the default if you don‘t need autoloading. Your method should return either an instance of the class, or nil.
NOTE: The find_file method is useful for getting the full path to a file which matches the name. That‘s what it‘s there for, so you should use it!
This method is invoked when a non-existing resource is accessed with #[]. By default, this method simply returns nil, effectively disabling autoloading.
You should override this method in your class to provide class-specific loading behavior, or leave it as the default if you don‘t need autoloading. Your method should return either an instance of the class, or nil.
NOTE: The find_file method is useful for getting the full path to a file which matches the name. That‘s what it‘s there for, so you should use it!
Returns the basename for the path (i.e. the filename without the directory). Same as File.basename
Returns the basename for the path (i.e. the filename without the directory). Same as File.basename
Checks every directory in @autoload_dirs for a file with the given name, and returns the path (directory and name) for the first match.
If no directories have a file with that name, return nil.