diff options
| author | Teddy Wing | 2015-04-14 17:27:31 -0400 |
|---|---|---|
| committer | Teddy Wing | 2015-04-14 17:27:31 -0400 |
| commit | eba2547a194b801596b43f6ba37b7d1b867a321d (patch) | |
| tree | e0a845af0cac64fa3e17752cf14a5cbeb988825e /board.rb | |
| parent | 1863abc09ec0af8a0026d4c170bfd50b11032b76 (diff) | |
| download | tic-tac-toe-eba2547a194b801596b43f6ba37b7d1b867a321d.tar.bz2 | |
Board: Method to unintelligently convert string coordinates to array
Take string coordinates in the form ":integer:,:integer:" and convert
them to [integer, integer]. We'll be using these converted coordinate
values to place a piece on the board.
Diffstat (limited to 'board.rb')
| -rw-r--r-- | board.rb | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -10,4 +10,17 @@ class Board def render "...\n" * 3 end + + # Raises an ArgumentError if integer conversion fails + def transform_coordinates(str) + coordinates = str.split(',') + + begin + coordinates[0] = Integer(coordinates[0]) + coordinates[1] = Integer(coordinates[1]) + + coordinates if coordinates.length > 1 + rescue + end + end end |
