Ruby では、

# 一旦、整数の2次元配列にする。[[1, 1], [2, 2], [3], [4, 4, 4], [5], [6]]

result_ary = input_ary = "1,1,2,2,3,4,4,4,5,6".split( "," ).
chunk_while{ |prev, nxt| prev == nxt }.each_with_object( [ ] ) do |ary, acc| # 蓄積変数は配列
if ary.length == 1
acc.push( ary[ 0 ] )
else
ary.each_with_index do |num, idx|
acc.push( "#{ num }-#{ idx + 1 }" )
end
end
end

puts result_ary.to_a.join( "," ) # カンマ区切り