Class: Metro::Image
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Metro::Image
- Defined in:
- lib/metro/image.rb
Overview
Image is a wrapper class for a Gosu Image. This allows for additional data to be stored without relying on monkey-patching on functionality.
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
The relative path of the image.
-
#tileable ⇒ Object
readonly
The tileability of the image.
Class Method Summary collapse
-
.create(options) ⇒ Object
Create an image given the window, path, and tileability.
-
.find_or_create(options) ⇒ Object
Finds an existing image or creates a new image given the window, path, and tileablilty.
Instance Method Summary collapse
- #dimensions ⇒ Object
-
#initialize(gosu_image, path, tileable) ⇒ Image
constructor
A new instance of Image.
Constructor Details
#initialize(gosu_image, path, tileable) ⇒ Image
Returns a new instance of Image.
9 10 11 12 13 |
# File 'lib/metro/image.rb', line 9 def initialize(gosu_image,path,tileable) super(gosu_image) @path = path @tileable = tileable end |
Instance Attribute Details
#path ⇒ Object (readonly)
The relative path of the image
16 17 18 |
# File 'lib/metro/image.rb', line 16 def path @path end |
#tileable ⇒ Object (readonly)
The tileability of the image
19 20 21 |
# File 'lib/metro/image.rb', line 19 def tileable @tileable end |
Class Method Details
.create(options) ⇒ Object
Create an image given the window, path, and tileability.
47 48 49 50 51 |
# File 'lib/metro/image.rb', line 47 def self.create() window, asset_path, tileable = create_params() gosu_image = Gosu::Image.new(window,asset_path.filepath,tileable) new gosu_image, asset_path.path, tileable end |
Instance Method Details
#dimensions ⇒ Object
21 22 23 |
# File 'lib/metro/image.rb', line 21 def dimensions Metro::Units::Dimensions.of width, height end |