Created
January 22, 2012 01:37
-
-
Save practicingruby/1654996 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Board | |
def self.from_file(filename) | |
board = new | |
File.open(filename) do |file| | |
line = file.gets.strip | |
board.add_territories(line.split(",")) | |
file.each_line do |line| | |
territory = line.strip | |
borders = file.gets.strip.split(",") | |
board.add_borders(territory, borders) | |
end | |
end | |
board | |
end | |
# other code similar to what you had before | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment