Class: TilesetTooling::Data::TileSet
- Inherits:
-
Dry::Struct
- Object
- Dry::Struct
- TilesetTooling::Data::TileSet
- Defined in:
- lib/tileset_tooling/data/tileset.rb
Overview
Class representing a TileSet’s information
Instance Method Summary collapse
-
#for_each_tile(&block) ⇒ Object
Runs the given bloc on each tile of the tileset.
-
#height ⇒ Object
Gets the height of the tileset/image.
-
#to_s ⇒ Object
Helper to print all information in the image.
-
#width ⇒ Object
Gets the width of the tileset/image.
Instance Method Details
#for_each_tile(&block) ⇒ Object
Runs the given bloc on each tile of the tileset
39 40 41 42 43 44 45 |
# File 'lib/tileset_tooling/data/tileset.rb', line 39 def for_each_tile(&block) rows.each do |row| row.tiles.each do |tile| block.call(tile) end end end |
#height ⇒ Object
Gets the height of the tileset/image
48 49 50 |
# File 'lib/tileset_tooling/data/tileset.rb', line 48 def height image.height end |
#to_s ⇒ Object
Helper to print all information in the image
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/tileset_tooling/data/tileset.rb', line 27 def to_s %( Image '#{original_image_path}' Tile height: #{tile_height} Tile width: #{tile_width} Margin: #{margin} Top offset: #{offset_top} Left offset: #{offset_left} Number of tiles: #{rows.count * rows[0].tiles.count}) end |
#width ⇒ Object
Gets the width of the tileset/image
53 54 55 |
# File 'lib/tileset_tooling/data/tileset.rb', line 53 def width image.width end |