#!/bin/ruby

$speeds = [ 30, 40, 50, 60, 70, 80, 90, 100, 120, 150, 200, 300, 400, 500 ]
$diam = [0.0625, 0.125, 0.1875, 0.25, 0.375, 0.5,
          0.625, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0,
          2.5, 3.0, 3.5, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0 ]

# I used to set a WIDTH of 794, but this seems needless
# if we set COLSPAN
def emit_td_italic ( text, c )
  print "<td"
  if c
    print " COLSPAN=\"#{c}\""
  end
#  if w
#    print " WIDTH=\"#{w}\""
#  end
  print ">\n"

  puts "<center><i><font size=+2>#{text}</font></i></center>"
  puts "</td>"
end

def emit_td_int ( text, w )
  print "<td"
  if w
    print " WIDTH=\"#{w}\""
  end
  print ">\n"

  puts "<center><b><font face=\"Arial\"><font size=-1>#{text}</font></font></b></center>"
  puts "</td>"
end

def emit_td ( text )
    emit_td_int text, 71
end

puts "<table BORDER=4 >"
puts "<tr VALIGN=CENTER>"

emit_td "Diameter of Work (inches)"
 
emit_td_italic "Desired surface speed (feet per minute)", $speeds.size
puts "</tr>"

puts "<tr>"
emit_td " "
$speeds.each { |s|
  emit_td s.to_s
}
puts "</tr>"

$diam.each { |d|
  puts "<tr>"
  diam_str = "%.3f" % d
  emit_td diam_str
  $speeds.each { |s|
    rpm = 12.0 * s / d / 3.14159
    if ( rpm < 5000.0 )
      rpm_str = "%.0f" % rpm
    else
      rpm_str = "---"
    end
    emit_td rpm_str
  }
  puts "</tr>"
}

puts "</table>"

# THE END
