Sha256: 68ce9b2bbfeb5c7a84a7b4b01c97c7cc78489ef5293101e69f331e258df6a7de

Contents?: true

Size: 617 Bytes

Versions: 5

Compression:

Stored size: 617 Bytes

Contents

module Cardgame
  class Deck
     include Enumerable

     def initialize
       @deck = Array.new
       [:hearts, :clubs, :diamonds, :spades].each do |suit|
         (1..13).each do |value|
           @deck << Card.new(:suit => suit, :value => value)
         end
       end
     end

     def [](index)
       @deck[index]
     end

     def each &block
       #TODO understand this
       @deck.each { |card| block.call(card) }
     end

     def length
       @deck.length
     end

    def shuffle!
      @deck.shuffle!
    end

    def pop
      @deck.pop
    end
   end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
warcards-0.0.7 lib/warcards/deck.rb
warcards-0.0.6 lib/warcards/deck.rb
warcards-0.0.5 lib/warcards/deck.rb
warcards-0.0.3 lib/warcards/deck.rb
warcards-0.0.2 lib/warcards/deck.rb