Class: Budgie::Map
Instance Attribute Summary collapse
-
#max ⇒ Object
readonly
Returns the value of attribute max.
Instance Method Summary collapse
- #[](x, y, z) ⇒ Object
- #[]=(x, y, z, value) ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(max = 0) ⇒ Map
constructor
A new instance of Map.
Methods included from Index
Constructor Details
Instance Attribute Details
#max ⇒ Object
Returns the value of attribute max.
7 8 9 |
# File 'lib/budgie/map.rb', line 7 def max @max end |
Instance Method Details
#[](x, y, z) ⇒ Object
14 15 16 |
# File 'lib/budgie/map.rb', line 14 def [](x, y, z) @data[to_index x][to_index y][to_index z] end |
#[]=(x, y, z, value) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/budgie/map.rb', line 18 def []=(x, y, z, value) self.max = x self.max = y self.max = z @data[to_index x][to_index y][to_index z] = value end |
#each(&block) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/budgie/map.rb', line 25 def each(&block) (-@max).upto(@max) do |x| (-@max).upto(@max) do |y| (-@max).upto(@max) do |z| yield x, y, z, self[x, y, z] end end end end |