Class: Bridge::Hand

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeHand

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

#cardsObject

Returns the value of attribute cards.



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

def cards
  @cards
end

#currentObject

Returns the value of attribute current.



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

def current
  @current
end

#playedObject

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_sObject



17
18
19
# File 'lib/bridge/hand.rb', line 17

def to_s
  cards.map(&:to_s).join(' ')
end