Class: Bridge::Deck

Inherits:
Object
  • Object
show all
Defined in:
lib/bridge/deck.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDeck

Returns a new instance of Deck.



5
6
7
8
# File 'lib/bridge/deck.rb', line 5

def initialize
  @cards = Card::RANKS.product(Card::SUITS).map { |a| Card.new(a[0],a[1]) }
  @cards.shuffle!
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/bridge/deck.rb', line 14

def method_missing(method, *args, &block)
  begin
    @cards.send(method, *args, &block)
  rescue Exception => e
    super
  end
end

Instance Attribute Details

#cardsObject

Returns the value of attribute cards.



3
4
5
# File 'lib/bridge/deck.rb', line 3

def cards
  @cards
end

Instance Method Details

#inspectObject



10
11
12
# File 'lib/bridge/deck.rb', line 10

def inspect
  cards.inspect
end