Class: RubySprites::Image
- Inherits:
-
Object
- Object
- RubySprites::Image
- Defined in:
- lib/lash-sprites/image.rb
Instance Attribute Summary collapse
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
-
#x ⇒ Object
Returns the value of attribute x.
-
#y ⇒ Object
Returns the value of attribute y.
Instance Method Summary collapse
- #area ⇒ Object
- #exists? ⇒ Boolean
-
#initialize(path, sprite, x = 0, y = 0, width = nil, height = nil) ⇒ Image
constructor
A new instance of Image.
- #mtime ⇒ Object
Constructor Details
#initialize(path, sprite, x = 0, y = 0, width = nil, height = nil) ⇒ Image
Returns a new instance of Image.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/lash-sprites/image.rb', line 7 def initialize(path, sprite, x = 0, y = 0, width = nil, height = nil) @path = path @sprite = sprite @x = x @y = y @width = nil @height = nil if exists? if !sprite.mtime.nil? && mtime < sprite.mtime @width = width @height = height end if @width.nil? || @height.nil? info = @sprite.graphics_manager.get_info(path) @width = info[:width] @height = info[:height] end end end |
Instance Attribute Details
#height ⇒ Object (readonly)
Returns the value of attribute height.
5 6 7 |
# File 'lib/lash-sprites/image.rb', line 5 def height @height end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
5 6 7 |
# File 'lib/lash-sprites/image.rb', line 5 def path @path end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
5 6 7 |
# File 'lib/lash-sprites/image.rb', line 5 def width @width end |
#x ⇒ Object
Returns the value of attribute x.
4 5 6 |
# File 'lib/lash-sprites/image.rb', line 4 def x @x end |
#y ⇒ Object
Returns the value of attribute y.
4 5 6 |
# File 'lib/lash-sprites/image.rb', line 4 def y @y end |
Instance Method Details
#area ⇒ Object
35 36 37 38 39 |
# File 'lib/lash-sprites/image.rb', line 35 def area return nil if @width.nil? @area = @width * @height if @area.nil? return @area end |
#exists? ⇒ Boolean
31 32 33 |
# File 'lib/lash-sprites/image.rb', line 31 def exists? return File.exists?(@sprite.file_root + @path) end |
#mtime ⇒ Object
41 42 43 44 |
# File 'lib/lash-sprites/image.rb', line 41 def mtime return File.mtime(@sprite.file_root + @path) if exists? return nil end |