summaryrefslogtreecommitdiffstats
path: root/CLI/ruby
diff options
context:
space:
mode:
Diffstat (limited to 'CLI/ruby')
-rw-r--r--CLI/ruby/lib/game_of_life/universe.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/CLI/ruby/lib/game_of_life/universe.rb b/CLI/ruby/lib/game_of_life/universe.rb
new file mode 100644
index 0000000..a8c9050
--- /dev/null
+++ b/CLI/ruby/lib/game_of_life/universe.rb
@@ -0,0 +1,26 @@
+# frozen_string_literal: true
+
+require "forwardable"
+
+module GameOfLife
+ class Universe
+ extend Forwardable
+
+ attr_accessor :universe
+ def_delegators :@universe, :[]
+
+ # Initialize the empty initial universe 2D array
+ # @param width [Integer] the width of the universe array
+ # @param height [Integer] the height of the universe array
+ def initialize(width:, height:)
+ @universe = Array.new(height) { Array.new(width) }
+ end
+
+ # Representation of the game of life universe
+ # @return [String] representing the current state
+ # @see ::GameOfLife::Cell#to_s
+ def to_s
+ @universe.map(&:join).join("\n")
+ end
+ end
+end