Method: Life::Board.from_text
- Defined in:
- lib/life/board.rb
.from_text(text) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/life/board.rb', line 43 def self.from_text(text) lines = text.split("\n") width = lines[0].size height = lines.size board = Life::Board.new(width, height) lines.each_with_index do |line, y| line.each_char.with_index do |char, x| board[x, y] = (char == "#") end end board end |