Class: Map
- Inherits:
-
Object
- Object
- Map
- Defined in:
- lib/map.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
-
#[](x, y) ⇒ Object
rubocop:disable Naming/MethodParameterName:.
- #describe ⇒ Object
-
#initialize(map_config: MapConfig.new) ⇒ Map
constructor
A new instance of Map.
- #render ⇒ Object
-
#tiles ⇒ Object
rubocop:enable Naming/MethodParameterName:.
Constructor Details
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
10 11 12 |
# File 'lib/map.rb', line 10 def config @config end |
Instance Method Details
#[](x, y) ⇒ Object
rubocop:disable Naming/MethodParameterName:
28 29 30 31 32 |
# File 'lib/map.rb', line 28 def [](x, y) raise ArgumentError, 'coordinates out of bounds' if y.nil? || y >= tiles.size || x.nil? || x >= tiles[y].size tiles[y][x] end |
#describe ⇒ Object
16 17 18 |
# File 'lib/map.rb', line 16 def describe tiles.map { |row| row.map(&:to_h) } end |
#render ⇒ Object
20 21 22 23 24 25 |
# File 'lib/map.rb', line 20 def render tiles.each do |row| row.each(&:render_to_standard_output) puts end end |
#tiles ⇒ Object
rubocop:enable Naming/MethodParameterName:
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/map.rb', line 35 def tiles return @tiles if @tiles generate_tiles generate_flora generate_roads generate_towns @tiles end |