Knuth-Plass linebreaking implementation in Ruby