Class: Table
- Inherits:
-
Object
- Object
- Table
- Defined in:
- lib/rora/model/table.rb
Instance Attribute Summary collapse
-
#board ⇒ Object
readonly
Returns the value of attribute board.
-
#deck ⇒ Object
readonly
Returns the value of attribute deck.
-
#pot ⇒ Object
readonly
Returns the value of attribute pot.
-
#seats ⇒ Object
readonly
Returns the value of attribute seats.
Instance Method Summary collapse
- #add(player, seat_number = nil) ⇒ Object
-
#initialize(seats = nil) ⇒ Table
constructor
A new instance of Table.
- #remove(player) ⇒ Object
- #reset ⇒ Object
Constructor Details
#initialize(seats = nil) ⇒ Table
Returns a new instance of Table.
7 8 9 10 11 12 |
# File 'lib/rora/model/table.rb', line 7 def initialize seats=nil @seats = Array.new(seats.nil? ? 9 : seats) @board = Board.new @pot = Pot.new @deck = Deck.new end |
Instance Attribute Details
#board ⇒ Object (readonly)
Returns the value of attribute board.
5 6 7 |
# File 'lib/rora/model/table.rb', line 5 def board @board end |
#deck ⇒ Object (readonly)
Returns the value of attribute deck.
5 6 7 |
# File 'lib/rora/model/table.rb', line 5 def deck @deck end |
#pot ⇒ Object (readonly)
Returns the value of attribute pot.
5 6 7 |
# File 'lib/rora/model/table.rb', line 5 def pot @pot end |
#seats ⇒ Object (readonly)
Returns the value of attribute seats.
5 6 7 |
# File 'lib/rora/model/table.rb', line 5 def seats @seats end |
Instance Method Details
#add(player, seat_number = nil) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/rora/model/table.rb', line 20 def add player, seat_number=nil if !location.nil? raise ArgumentException, "Seat #{seat_number} is already taken by another player." if @seats[seat_number - 1] != nil @seats[seat_number - 1] = player else @seats.each_index do |x| if @seats[x].nil? @seats[x] = player return end end end self end |
#remove(player) ⇒ Object
35 36 37 38 |
# File 'lib/rora/model/table.rb', line 35 def remove player @seats.delete player self end |
#reset ⇒ Object
14 15 16 17 18 |
# File 'lib/rora/model/table.rb', line 14 def reset @board = Board.new @pot = Pot.new @deck = Deck.new end |