Class: AcpcPokerTypes::Seat

Inherits:
Integer
  • Object
show all
Defined in:
lib/acpc_poker_types/seat.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(seat, num_seats_at_table) ⇒ Seat

Returns a new instance of Seat.



14
15
16
17
18
19
# File 'lib/acpc_poker_types/seat.rb', line 14

def initialize(seat, num_seats_at_table)
  @seat = (seat_number(seat) % num_seats_at_table).to_i
  @table_size = num_seats_at_table

  super @seat
end

Instance Attribute Details

#seatObject (readonly)

Returns the value of attribute seat.



6
7
8
# File 'lib/acpc_poker_types/seat.rb', line 6

def seat
  @seat
end

#table_sizeObject (readonly)

Returns the value of attribute table_size.



6
7
8
# File 'lib/acpc_poker_types/seat.rb', line 6

def table_size
  @table_size
end

Class Method Details

.in_bounds?(seat, num_seats) ⇒ Bool

Returns Reports whether or not seat represents an out of bounds seat for the number of seats, num_seats.

Returns:

  • (Bool)

    Reports whether or not seat represents an out of bounds seat for the number of seats, num_seats.



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

def self.in_bounds?(seat, num_seats)
  seat < num_seats && seat >= 0
end

Instance Method Details

#n_seats_away(n) ⇒ Object



32
33
34
# File 'lib/acpc_poker_types/seat.rb', line 32

def n_seats_away(n)
  Seat.new((n + @seat) % @table_size, @table_size)
end

#seats_from(other_player) ⇒ Object



29
30
31
# File 'lib/acpc_poker_types/seat.rb', line 29

def seats_from(other_player)
  self.class.new(other_player, @table_size).seats_to(@seat)
end

#seats_to(other_player) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'lib/acpc_poker_types/seat.rb', line 20

def seats_to(other_player)
  other_seat = self.class.new(other_player, @table_size)

  if @seat > other_seat
    other_seat + @table_size
  else
    other_seat
  end - @seat
end