Class: AcpcPokerTypes::BoardCards
- Inherits:
-
Array
- Object
- Array
- AcpcPokerTypes::BoardCards
- Defined in:
- lib/acpc_poker_types/board_cards.rb
Instance Method Summary collapse
- #array_push ⇒ Object
-
#initialize(board_cards = [[]]) ⇒ BoardCards
constructor
A new instance of BoardCards.
- #next_round! ⇒ Object
- #push(new_element) ⇒ Object (also: #<<)
- #round ⇒ Object
-
#to_acpc ⇒ String
The string representation of these board cards.
-
#to_s ⇒ String
(also: #to_str)
The string representation of these board cards.
Constructor Details
#initialize(board_cards = [[]]) ⇒ BoardCards
Returns a new instance of BoardCards.
6 7 8 |
# File 'lib/acpc_poker_types/board_cards.rb', line 6 def initialize(board_cards=[[]]) super(board_cards.map { |elem| AcpcPokerTypes::PileOfCards.new elem }) end |
Instance Method Details
#array_push ⇒ Object
14 |
# File 'lib/acpc_poker_types/board_cards.rb', line 14 alias_method :array_push, :push |
#next_round! ⇒ Object
16 17 18 19 |
# File 'lib/acpc_poker_types/board_cards.rb', line 16 def next_round! self.array_push AcpcPokerTypes::PileOfCards.new self end |
#push(new_element) ⇒ Object Also known as: <<
21 22 23 24 |
# File 'lib/acpc_poker_types/board_cards.rb', line 21 def push(new_element) self.last.push new_element self end |
#round ⇒ Object
10 11 12 |
# File 'lib/acpc_poker_types/board_cards.rb', line 10 def round self.length - 1 end |
#to_acpc ⇒ String
Returns The string representation of these board cards.
41 42 43 44 45 46 47 48 49 |
# File 'lib/acpc_poker_types/board_cards.rb', line 41 def to_acpc if all? { |pile_for_round| pile_for_round.empty? } '' else '/' + (map do |pile_for_round| (pile_for_round.map { |card| card.to_acpc }).join end).join('/') end end |
#to_s ⇒ String Also known as: to_str
Returns The string representation of these board cards.
29 30 31 32 33 34 35 |
# File 'lib/acpc_poker_types/board_cards.rb', line 29 def to_s if all? { |pile_for_round| pile_for_round.empty? } '' else '/' + (map { |pile_for_round| pile_for_round.join }).join('/') end end |