summaryrefslogtreecommitdiffstats
path: root/CLI/ruby/lib
diff options
context:
space:
mode:
authora14m <[email protected]>2020-12-03 15:25:27 +0100
committera14m <[email protected]>2020-12-03 15:25:27 +0100
commit94a9071fc00d6c14c359d31f7b576f9257d51219 (patch)
treecee0c6e8abdfdf367a5b6ad7fc2951c5a1c682e8 /CLI/ruby/lib
parente9e61b667af268b1f1da40f2ed2cd5bf30016456 (diff)
Minor fixes to the documentation to look better
Diffstat (limited to 'CLI/ruby/lib')
-rw-r--r--CLI/ruby/lib/game_of_life/cell.rb5
-rw-r--r--CLI/ruby/lib/game_of_life/generators/input.rb2
-rw-r--r--CLI/ruby/lib/game_of_life/universe.rb13
3 files changed, 11 insertions, 9 deletions
diff --git a/CLI/ruby/lib/game_of_life/cell.rb b/CLI/ruby/lib/game_of_life/cell.rb
index c5fb002..97a4e05 100644
--- a/CLI/ruby/lib/game_of_life/cell.rb
+++ b/CLI/ruby/lib/game_of_life/cell.rb
@@ -33,8 +33,9 @@ module GameOfLife
# @return [GameOfLife::Cell] representing the new state in the next generation
#
# @note There are some optimizations of returning a new object only when the state changes, otherwise returning self
- # This optimization is done to limit the spacial complexity to O(2*witdht*height) in the worst case scenario
- # and to O(width * hight) in the best case scenario (when the universe is stale and don't evolve anymore).
+ # This optimization is done to limit the spacial complexity to `O(2n^2) = O(2*witdht*height)`
+ # in the worst case scenario, and to `O(n^2) = O(width * hight)` in the best case scenario
+ # (when the universe is stale and don't evolve anymore).
# @see #living_neighbors
def evolve!(neighbors)
return repopulate! if dead? && living_neighbors(neighbors) == 3
diff --git a/CLI/ruby/lib/game_of_life/generators/input.rb b/CLI/ruby/lib/game_of_life/generators/input.rb
index 05aab1c..c0d96c1 100644
--- a/CLI/ruby/lib/game_of_life/generators/input.rb
+++ b/CLI/ruby/lib/game_of_life/generators/input.rb
@@ -26,7 +26,7 @@ module GameOfLife
# Populate the {GameOfLife::Universe} with reference to the parsed input 2D array (True/False)
# @param parsed_input [Array<Array<True|False>>]
- # @param widht [Integer] width of the generated cyclic universe
+ # @param width [Integer] width of the generated cyclic universe
# @param height [Integer] height of the generated cyclic universe
# @return [GameOfLife::Universe] populated with the parsed input
private def populate(parsed_input:, width:, height:)
diff --git a/CLI/ruby/lib/game_of_life/universe.rb b/CLI/ruby/lib/game_of_life/universe.rb
index 5a25b99..f4296dd 100644
--- a/CLI/ruby/lib/game_of_life/universe.rb
+++ b/CLI/ruby/lib/game_of_life/universe.rb
@@ -27,7 +27,7 @@ module GameOfLife
# Update the current state of the universe (according to the game of life laws) and
# set the current state to the next future generation
#
- # This have computational order O(width*height)
+ # This have computational order `O(n^2) = O(width * height)`
# It loops over all the universe cells and evolves them to the next generation
# @see #neighbors
def evolve!
@@ -39,11 +39,9 @@ module GameOfLife
@current = Marshal.load(Marshal.dump(@future))
end
- # Return the array of all the neighboring cells using the circular universe array
- # @param universe [Array<GameOfLife::Cell>] the {GameOfLife::Universe#current} state of universe
- # @return [Array<GameOfLife::Cell>] of all the immediate neighboring cells
- # @example given a cell "C" in a universe of cells "." the immediate neighbors would be "x" as in
- # the following different examples
+ # Return the array of all the neighboring cells using the circular universe array, <br/>
+ # given a cell "C" in a universe of cells "." the immediate neighbors would be "x" as in
+ # the following different examples
#
# ..... | .xxx. | .xCx. | xCx.. | Cx..x | xx..x |
# .xxx. | .xCx. | .xxx. | xxx.. | xx..x | Cx..x |
@@ -51,7 +49,10 @@ module GameOfLife
# .xxx. | ..... | ..... | ..... | ..... | ..... |
# ..... | ..... | .xxx. | xxx.. | xx..x | ..... |
#
+ # @param cell [GameOfLife::Cell] the to return the neighboring cells from the universe current plane
+ # @return [Array<GameOfLife::Cell>] of all the immediate neighboring cells
# @smell AbcSize higher than configuration, but needed to return the neighboring cells array
+ #
# rubocop:disable Metrics/AbcSize
private def neighbors(cell)
x, y = cell.x, cell.y # rubocop:disable Style/ParallelAssignment