Class: Model::Piece

Inherits:
Object
  • Object
show all
Defined in:
lib/tic_tac_toe/model/piece.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, move_klass) ⇒ Piece

Returns a new instance of Piece.



6
7
8
9
# File 'lib/tic_tac_toe/model/piece.rb', line 6

def initialize(name, move_klass)
  @name = name
  @move_klass = move_klass
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/tic_tac_toe/model/piece.rb', line 3

def name
  @name
end

#teamObject

Returns the value of attribute team.



4
5
6
# File 'lib/tic_tac_toe/model/piece.rb', line 4

def team
  @team
end

Instance Method Details

#moves(board) ⇒ Object



11
12
13
# File 'lib/tic_tac_toe/model/piece.rb', line 11

def moves(board)
  @move_klass.generate_moves(self, board)
end