title: Ruby: War card game, dealing cards to players
body: <p>So I am not asking anyone to solve this for me, but I do need some help. I am pretty new to Object-Oriented Programming, but it's starting to make sense for me. Below is the code I have so far for the War card game. I am not concerned with the Suits at the moment, though I do know how to add them in if need be. Basically, my next step is to figure out how to deal 26 cards to each player. </p>
  
  <p>What this code does now is shuffles the deck using the Fisher-Yates algorithm, and outputs a string containing the now shuffled deck. I thought this would return an array since I was using the "to_a" method, but I don't think that's the case.</p>
  
  <p>How do I then deal this deck to each player? Do I need a Class for the Table or players? Any help in the right direction would be awesome. Again, please do not solve it for me. I want to figure this out for myself as much as possible.
  EDIT: Using 1.9.3, if that's useful.</p>
  
  <pre><code>class Card
      VALUE = %w(2 3 4 5 6 7 8 9 10 J Q K A)
  
      attr_accessor :rank
  
      def initialize(id)
          self.rank = VALUE[id % 13]
      end
  end
  
  class Deck 
      attr_accessor :cards
      def initialize
          self.cards = (0..51).to_a.shuffle.collect { |id| Card.new(id) }
      end
  end
  
  class Array
      def shuffle!
          each_index do |i|
              r = rand(length-i) + i
              self[r], self[i] = self[i], self[r]
          end
      end
  
      def shuffle
          dup.shuffle!
      end
  end
  
  
  d = Deck.new
  d.cards.each do |card|
      print "#{card.rank} "
  end
  </code></pre>