class Bridge::Deck

Attributes

cards[RW]

Public Class Methods

new() click to toggle source
# File lib/bridge/deck.rb, line 7
def initialize
  @cards = Card::RANKS.product(Card::SUITS).map { |a| Card.new(a[0],a[1]) }
  @cards.shuffle!(random: SecureRandom)
end

Public Instance Methods

inspect() click to toggle source
# File lib/bridge/deck.rb, line 21
def inspect
  cards.inspect
end
method_missing(method, *args, &block) click to toggle source
Calls superclass method
# File lib/bridge/deck.rb, line 25
def method_missing(method, *args, &block)
  begin
    @cards.send(method, *args, &block)
  rescue Exception => e
    super
  end
end
shuffle() click to toggle source
# File lib/bridge/deck.rb, line 17
def shuffle
  @cards.shuffle(random: SecureRandom)
end
shuffle!() click to toggle source

make sure shuffling is as random as possible

# File lib/bridge/deck.rb, line 13
def shuffle!
  @cards.shuffle!(random: SecureRandom)
end