Consider: [part1, part2, part3].reject(&:blank?).join("\n")