Class: GameOfLife::Plane
- Inherits:
-
Array
- Object
- Array
- GameOfLife::Plane
- Defined in:
- lib/game_of_life/plane.rb
Overview
Custom Plane class that represent a cyclic/circular plane/array This class would always return an element unless the array is empty
Instance Method Summary collapse
-
#[](index) ⇒ Object
Extending the default array behaviour by treating the array as cyclic/circular object.
Instance Method Details
#[](index) ⇒ Object
Extending the default array behaviour by treating the array as cyclic/circular object
22 23 24 25 |
# File 'lib/game_of_life/plane.rb', line 22 def [](index) return nil if empty? super(index % size) end |