Class: BoardCards
- Inherits:
-
PileOfCards
- Object
- Array
- PileOfCards
- BoardCards
- Defined in:
- lib/acpc_poker_types/board_cards.rb
Overview
List of community board cards.
Instance Attribute Summary collapse
-
#round ⇒ Object
readonly
Returns the value of attribute round.
Instance Method Summary collapse
-
#initialize ⇒ BoardCards
constructor
A new instance of BoardCards.
- #next_round! ⇒ Object
- #push(new_element) ⇒ Object (also: #<<)
-
#to_acpc ⇒ String
The string representation of these board cards.
-
#to_s ⇒ String
(also: #to_str)
The string representation of these board cards.
Methods inherited from PileOfCards
Constructor Details
#initialize ⇒ BoardCards
Returns a new instance of BoardCards.
13 |
# File 'lib/acpc_poker_types/board_cards.rb', line 13 def initialize() @round = nil; next_round! end |
Instance Attribute Details
#round ⇒ Object (readonly)
Returns the value of attribute round.
11 12 13 |
# File 'lib/acpc_poker_types/board_cards.rb', line 11 def round @round end |
Instance Method Details
#next_round! ⇒ Object
15 16 17 18 19 |
# File 'lib/acpc_poker_types/board_cards.rb', line 15 def next_round! @round = if @round then @round + 1 else 0 end self[@round] = 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[@round].push new_element self 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 |