Class: TilesetTooling::Data::TileSetBase
- Inherits:
-
Dry::Struct
- Object
- Dry::Struct
- TilesetTooling::Data::TileSetBase
- Defined in:
- lib/tileset_tooling/data/tileset.rb
Overview
Class representing any TileSet’s information
Direct Known Subclasses
Instance Method Summary collapse
-
#for_each_tile(&block) ⇒ Object
Runs the given bloc on each tile of the tileset.
-
#nb_tiles_per_column ⇒ Object
Gets the number of tiles per column.
-
#nb_tiles_per_row ⇒ Object
Gets the number of tiles per row.
-
#tile_at(row_index, column_index) ⇒ Object
Gets the tile at the specified row/column.
Instance Method Details
#for_each_tile(&block) ⇒ Object
Runs the given bloc on each tile of the tileset
27 28 29 30 31 32 33 |
# File 'lib/tileset_tooling/data/tileset.rb', line 27 def for_each_tile(&block) rows.each do |row| row.tiles.each do |tile| block.call(tile) end end end |
#nb_tiles_per_column ⇒ Object
Gets the number of tiles per column
41 42 43 |
# File 'lib/tileset_tooling/data/tileset.rb', line 41 def nb_tiles_per_column rows.length end |
#nb_tiles_per_row ⇒ Object
Gets the number of tiles per row
36 37 38 |
# File 'lib/tileset_tooling/data/tileset.rb', line 36 def nb_tiles_per_row rows[0].tiles.length end |
#tile_at(row_index, column_index) ⇒ Object
Gets the tile at the specified row/column
46 47 48 |
# File 'lib/tileset_tooling/data/tileset.rb', line 46 def tile_at(row_index, column_index) rows[row_index].tiles[column_index] end |