Class: BoardCards

Inherits:
PileOfCards show all
Defined in:
lib/acpc_poker_types/board_cards.rb

Overview

List of community board cards.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from PileOfCards

#to_poker_hand_strength

Constructor Details

#initializeBoardCards

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

#roundObject (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_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