Class: Pouch

Inherits:
Object
  • Object
show all
Defined in:
lib/pouch.rb

Instance Method Summary collapse

Constructor Details

#initialize(tiles, rng = Random.new) ⇒ Pouch

Returns a new instance of Pouch.



2
3
4
5
# File 'lib/pouch.rb', line 2

def initialize(tiles, rng = Random.new)
  @tiles = tiles
  @rng = rng
end

Instance Method Details

#draw(num) ⇒ Object



7
8
9
10
# File 'lib/pouch.rb', line 7

def draw(num)
  shuffle
  @tiles.shift(num)
end

#exchange(tiles) ⇒ Object



12
13
14
15
16
# File 'lib/pouch.rb', line 12

def exchange(tiles)
  new_tiles = draw(tiles.length)
  @tiles.concat(tiles)
  new_tiles
end