How to link the output of a Vector Math node to another node?
The Vector Math node actually has 2 outputs : One of type Vector, and one of type float. They get hidden / shown depending on the node's operation.
The float type is accessed with the second index of the outputs. Change your last line to :
mat_ruby.node_tree.links.new(math.outputs[1], ramp.inputs[0])

Or (not advised since it is language-dependant)
mat_ruby.node_tree.links.new(math.outputs[&quot;Value&quot;], ramp.inputs[0])