Class: Bridge::Hand
- Inherits:
-
Object
- Object
- Bridge::Hand
- Defined in:
- lib/bridge/hand.rb
Instance Attribute Summary collapse
-
#cards ⇒ Object
Returns the value of attribute cards.
-
#current ⇒ Object
Returns the value of attribute current.
-
#played ⇒ Object
Returns the value of attribute played.
Instance Method Summary collapse
-
#initialize ⇒ Hand
constructor
A new instance of Hand.
- #method_missing(m, *args, &block) ⇒ Object
- #to_json(opts = {}) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ Hand
Returns a new instance of Hand.
5 6 7 |
# File 'lib/bridge/hand.rb', line 5 def initialize self.cards = [] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/bridge/hand.rb', line 9 def method_missing(m, *args, &block) if cards.respond_to?(m) cards.send(m, *args, &block) else super end end |
Instance Attribute Details
#cards ⇒ Object
Returns the value of attribute cards.
3 4 5 |
# File 'lib/bridge/hand.rb', line 3 def cards @cards end |
#current ⇒ Object
Returns the value of attribute current.
3 4 5 |
# File 'lib/bridge/hand.rb', line 3 def current @current end |
#played ⇒ Object
Returns the value of attribute played.
3 4 5 |
# File 'lib/bridge/hand.rb', line 3 def played @played end |
Instance Method Details
#to_json(opts = {}) ⇒ Object
21 22 23 |
# File 'lib/bridge/hand.rb', line 21 def to_json opts = {} cards.to_json end |
#to_s ⇒ Object
17 18 19 |
# File 'lib/bridge/hand.rb', line 17 def to_s cards.map(&:to_s).join(' ') end |