Class: AcpcPokerTypes::BoardCards

Inherits:
Array
  • Object
show all
Defined in:
lib/acpc_poker_types/board_cards.rb

Instance Method Summary collapse

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_pushObject



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

#roundObject



10
11
12
# File 'lib/acpc_poker_types/board_cards.rb', line 10

def round
  self.length - 1
end

#to_acpcString

Returns The string representation of these board cards.

Returns:

  • (String)

    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_sString Also known as: to_str

Returns The string representation of these board cards.

Returns:

  • (String)

    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