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
- #shuffle ⇒ Object
-
#shuffle! ⇒ Object
make sure shuffling is as random as possible.
Constructor Details
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
25 26 27 28 29 30 31 |
# 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 |
Instance Attribute Details
#cards ⇒ Object
Returns the value of attribute cards.
5 6 7 |
# File 'lib/bridge/deck.rb', line 5 def cards @cards end |
Instance Method Details
#inspect ⇒ Object
21 22 23 |
# File 'lib/bridge/deck.rb', line 21 def inspect cards.inspect end |
#shuffle ⇒ Object
17 18 19 |
# File 'lib/bridge/deck.rb', line 17 def shuffle @cards.shuffle(random: SecureRandom) end |
#shuffle! ⇒ Object
make sure shuffling is as random as possible
13 14 15 |
# File 'lib/bridge/deck.rb', line 13 def shuffle! @cards.shuffle!(random: SecureRandom) end |