Skip to content

Instantly share code, notes, and snippets.

@practicingruby
Created January 22, 2012 01:37
Show Gist options
  • Save practicingruby/1654996 to your computer and use it in GitHub Desktop.
Save practicingruby/1654996 to your computer and use it in GitHub Desktop.
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