Skip to content

Instantly share code, notes, and snippets.

@guilhermeteodoro
Created September 29, 2015 00:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guilhermeteodoro/ca898a6cfbcb2d3e8b44 to your computer and use it in GitHub Desktop.
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.
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