Cleaning up and writing tests
This commit is contained in:
@@ -7,12 +7,19 @@ require './position'
|
||||
# indexing as well as point type indexing
|
||||
class UniverseArray < Array
|
||||
def initialize
|
||||
super
|
||||
end
|
||||
|
||||
def [](index, *rest)
|
||||
if index.is_a?(Position)
|
||||
return self[position.y_pos][position.x_pos]
|
||||
return self[index.y_pos][index.x_pos]
|
||||
else
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
def []=(index, *rest)
|
||||
if index.is_a?(Position)
|
||||
return self[index.y_pos][index.x_pos] = rest[0]
|
||||
else
|
||||
super
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user