Turn Ruby array into strings - problem with my code?

As the question is currently posed, you have 3 things going wrong:

First, you're trying to create private methods without first calling a class. This also explains the extra end. To fix that, we can add the class call at the beginning like so:

class Test

private
  def cards
    %w(6♠ 3♦ A♣ J♦ J♥)
  end

  def to_s
    cards.map {|card| "-" + card.to_s}.join("-")
    end
end

Second, we need to actually use the class somehow. We can use Class.new for this, like so:

class Test

private
  def cards
    %w(6♠ 3♦ A♣ J♦ J♥)
  end

  def to_s
    cards.map {|card| "-" + card.to_s}.join("-")
    end
end

puts Test.new
#=>  "-6♠--3♦--A♣--J♦--J♥"

I can only assume your posted code section was just incomplete, that you weren't having issues with the first couple things, and that you're just having problems with the formatting in that output line. If so, there are many different ways to do this, but your main issue is the following section of your code:

"-" + card.to_s}.join("-")

You are iterating over the array and adding a "-" before every element. You are then joining up those elements with a redundant "-" to create your string. You need to get rid of one or the other. I suggest just getting rid of the latter like so:

cards.map {|card| "-" + card.to_s}.join

Its also worth noting that your array elements are already strings, so the .to_s is unnecessary. Your line could therefore be reduced to:

cards.map {|card| "-" + card}.join

This will result in #=> "-6♠-3♦-A♣-J♦-J♥"

The only thing missing now is that last dash. To fix that, we just add the dash independently at the end of your newly joined array like so:

cards.map {|card| "-" + card}.join + "-"

The completed test would then look like this:

class Test

private
  def cards
    %w(6♠ 3♦ A♣ J♦ J♥)
  end

  def to_s
    cards.map {|card| "-" + card}.join + "-"
    end
end

puts Test.new
#=>  "-6♠-3♦-A♣-J♦-J♥-"

At the end of the day though, your string formatting issues could essentially be addressed by just replacing ("-") with +"-"