Class: AcpcPokerTypes::Seat
- Inherits:
-
Integer
- Object
- Integer
- AcpcPokerTypes::Seat
- Defined in:
- lib/acpc_poker_types/seat.rb
Instance Attribute Summary collapse
-
#seat ⇒ Object
readonly
Returns the value of attribute seat.
-
#table_size ⇒ Object
readonly
Returns the value of attribute table_size.
Class Method Summary collapse
-
.in_bounds?(seat, num_seats) ⇒ Bool
Reports whether or not
seat
represents an out of bounds seat for the number of seats,num_seats
.
Instance Method Summary collapse
-
#initialize(seat, num_seats_at_table) ⇒ Seat
constructor
A new instance of Seat.
- #n_seats_away(n) ⇒ Object
- #seats_from(other_player) ⇒ Object
- #seats_to(other_player) ⇒ Object
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
#seat ⇒ Object (readonly)
Returns the value of attribute seat.
6 7 8 |
# File 'lib/acpc_poker_types/seat.rb', line 6 def seat @seat end |
#table_size ⇒ Object (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
.
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 |