Polynomial class in Ruby