Class: Bridge::Deck
- Inherits:
-
Object
- Object
- Bridge::Deck
- Defined in:
- lib/bridge/deck.rb
Instance Attribute Summary collapse
-
#cards ⇒ Object
Returns the value of attribute cards.
Instance Method Summary collapse
-
#initialize ⇒ Deck
constructor
A new instance of Deck.
- #inspect ⇒ Object
- #method_missing(method, *args, &block) ⇒ Object
Constructor Details
#initialize ⇒ Deck
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
#cards ⇒ Object
Returns the value of attribute cards.
3 4 5 |
# File 'lib/bridge/deck.rb', line 3 def cards @cards end |
Instance Method Details
#inspect ⇒ Object
10 11 12 |
# File 'lib/bridge/deck.rb', line 10 def inspect cards.inspect end |