Class: Bridge::Deal
- Inherits:
-
Object
- Object
- Bridge::Deal
- Defined in:
- lib/bridge/deal.rb
Instance Attribute Summary collapse
-
#deck ⇒ Object
Returns the value of attribute deck.
-
#hands ⇒ Object
Returns the value of attribute hands.
Class Method Summary collapse
Instance Method Summary collapse
-
#deal! ⇒ Object
deals one card per hand on a cycle until we run out of cards.
-
#initialize ⇒ Deal
constructor
A new instance of Deal.
- #method_missing(m, *args, &block) ⇒ Object
- #to_page ⇒ Object
Constructor Details
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/bridge/deal.rb', line 28 def method_missing(m, *args, &block) if hands.respond_to?(m) hands.send(m, *args, &block) else super end end |
Instance Attribute Details
#deck ⇒ Object
Returns the value of attribute deck.
3 4 5 |
# File 'lib/bridge/deal.rb', line 3 def deck @deck end |
#hands ⇒ Object
Returns the value of attribute hands.
3 4 5 |
# File 'lib/bridge/deal.rb', line 3 def hands @hands end |
Class Method Details
.from_page ⇒ Object
24 25 26 |
# File 'lib/bridge/deal.rb', line 24 def self.from_page # create deal and hands based on HEX bridge book page number end |
Instance Method Details
#deal! ⇒ Object
deals one card per hand on a cycle until we run out of cards
16 17 18 |
# File 'lib/bridge/deal.rb', line 16 def deal! hands.cycle(deck.size/hands.size) { |hand| hand << deck.shift } end |
#to_page ⇒ Object
20 21 22 |
# File 'lib/bridge/deal.rb', line 20 def to_page # returns HEX bridge book page value end |