Class: JustBackgammon::Piece
- Inherits:
-
Object
- Object
- JustBackgammon::Piece
- Extended by:
- Common
- Defined in:
- lib/just_backgammon/piece.rb
Overview
Piece
A piece owned by a player that moves around the board.
Instance Attribute Summary collapse
-
#owner ⇒ Fixnum
readonly
The owner of the piece.
Instance Method Summary collapse
-
#as_json ⇒ Hash
A hashed serialized representation of the piece.
-
#initialize(owner:) ⇒ Piece
constructor
A new instance of Piece.
Methods included from Common
Constructor Details
#initialize(owner:) ⇒ Piece
A new instance of Piece.
Example:
# Instantiates a new Piece
JustBackgammon::Piece.new(1)
19 20 21 |
# File 'lib/just_backgammon/piece.rb', line 19 def initialize(owner:) @owner = owner end |
Instance Attribute Details
#owner ⇒ Fixnum (readonly)
Returns the owner of the piece.
24 25 26 |
# File 'lib/just_backgammon/piece.rb', line 24 def owner @owner end |
Instance Method Details
#as_json ⇒ Hash
A hashed serialized representation of the piece.
29 30 31 |
# File 'lib/just_backgammon/piece.rb', line 29 def as_json { owner: owner } end |