Created
September 29, 2015 00:53
-
-
Save guilhermeteodoro/ca898a6cfbcb2d3e8b44 to your computer and use it in GitHub Desktop.
Bio Ritmo chess table challenge: generates a chess table in a html file.
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
require 'fileutils' | |
html = <<-eos | |
<!doctype html> | |
<html lang='pt-BR'> | |
<head> | |
<meta charset='utf-8'> | |
<title>Super Xadrez</title> | |
<meta name='description' content='Bio Ritmo xadrez challenge'> | |
<meta name='author' content='Guilherme Teodoro'> | |
</head> | |
<body> | |
<table style='height: 500px; width: 500px; border: 1px solid black; padding: 0'> | |
eos | |
(1..8).each do |line| | |
html << "<tr>\n" | |
color = line % 2 == 0 ? 'white' : 'black' | |
(1..8).each do |col| | |
html << "<td style='background-color:#{ color }; height: 12.5%; width: 12.5%'></td>\n" | |
color = color == 'black' ? 'white' : 'black' | |
end | |
html << "</tr>\n" | |
end | |
html << "</table>\n</body>" | |
File.open('index.html', 'w') do |file| | |
file.puts html | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment