]> git.openstreetmap.org Git - rails.git/blobdiff - vendor/gems/rspec-1.1.2/examples/stories/game-of-life/life/game.rb
added RSpec and RSpec on Rails
[rails.git] / vendor / gems / rspec-1.1.2 / examples / stories / game-of-life / life / game.rb
diff --git a/vendor/gems/rspec-1.1.2/examples/stories/game-of-life/life/game.rb b/vendor/gems/rspec-1.1.2/examples/stories/game-of-life/life/game.rb
new file mode 100644 (file)
index 0000000..5411b01
--- /dev/null
@@ -0,0 +1,23 @@
+class Game
+  attr_accessor :grid
+  def initialize(rows,cols)
+    @grid = Grid.new(rows, cols)
+  end
+  
+  def create_at(row,col)
+    @grid.create_at(row,col)
+  end
+  
+  def destroy_at(row,col)
+    @grid.destroy_at(row, col)
+  end
+  
+  def self.from_string(dots)
+    grid = Grid.from_string(dots)
+    game = new(grid.rows, grid.columns)
+    game.instance_eval do
+      @grid = grid
+    end
+    return game
+  end
+end