class Gosling::ImageLibrary
A cached Gosu::Image repository.
Public Class Methods
get(filename)
click to toggle source
When passed the path to an image, it first checks to see if that image is in the cache. If so, it returns the cached Gosu::Image. Otherwise, it loads the image, stores it in the cache, and returns it.
# File lib/gosling/image_library.rb, line 16 def self.get(filename) unless @@cache.has_key?(filename) raise ArgumentError.new("File not found: '#{filename}' in '#{Dir.pwd}'") unless File.exists?(filename) @@cache[filename] = Gosu::Image.new(filename, tileable: true) end @@cache[filename] end