Class: Seat

Inherits:
Object
  • Object
show all
Defined in:
lib/rora/model/seat.rb

Overview

A seat at a poker table.

Once a table is constructed, each seat at the table will contain a reference to the seat before it and the seat after it. In effect, the seat implements a very basic doubly-linked list.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(number) ⇒ Seat

Returns a new instance of Seat.

Raises:

  • (ArgumentError)


12
13
14
15
# File 'lib/rora/model/seat.rb', line 12

def initialize number
  raise ArgumentError, "Must create a seat number with a value of 1 or greater" if number < 1
  @number = number
end

Instance Attribute Details

#buttonObject

Returns the value of attribute button.



9
10
11
# File 'lib/rora/model/seat.rb', line 9

def button
  @button
end

#nextObject

Returns the value of attribute next.



9
10
11
# File 'lib/rora/model/seat.rb', line 9

def next
  @next
end

#numberObject (readonly)

Returns the value of attribute number.



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

def number
  @number
end

#playerObject

Returns the value of attribute player.



9
10
11
# File 'lib/rora/model/seat.rb', line 9

def player
  @player
end

#prevObject

Returns the value of attribute prev.



9
10
11
# File 'lib/rora/model/seat.rb', line 9

def prev
  @prev
end

Instance Method Details

#button?Boolean

Determines whether this seat has the dealer button.

Returns:

  • (Boolean)


23
24
25
# File 'lib/rora/model/seat.rb', line 23

def button?
  return !button.nil?
end

#taken?Boolean

Determines whether the seat is taken.

Returns:

  • (Boolean)


18
19
20
# File 'lib/rora/model/seat.rb', line 18

def taken?
  return !@player.nil?
end

#to_sObject



27
28
29
# File 'lib/rora/model/seat.rb', line 27

def to_s
  "Seat: #{@number}"
end