ActiveSupportを使用できる場合、チートは次のとおりです。
require 'active_support/core_ext/array/conversions'
stuff.map{|k,v| "#{k} contains a #{v.to_sentence}"}.join(" and ")
結果:
1.9.3p125 > require 'active_support/core_ext/array/conversions'
=> true
1.9.3p125 > stuff.map{|k,v| "#{k} contains a #{v.to_sentence}"}.join(" and ")
=> "pack_one contains a blue_item and red_item and pack_two contains a green_item, purple_item, and yellow_item"
編集: オックスフォードのカンマを取り除くには、明示的にlast_word_connector
オプションを指定します:
1.9.3p125 > stuff.map{|k,v| "#{k} contains a #{v.to_sentence(last_word_connector: " and ")}"}.join(" and ")
=> "pack_one contains a blue_item and red_item and pack_two contains a green_item, purple_item and yellow_item"