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
-
#id ⇒ Fixnum
readonly
The identifier of the piece.
-
#owner ⇒ Fixnum
readonly
The owner of the piece.
Instance Method Summary collapse
-
#as_json ⇒ Hash
A hashed serialized representation of the piece.
-
#initialize(id:, owner:) ⇒ Piece
constructor
A new instance of Piece.
Methods included from Common
Constructor Details
#initialize(id:, owner:) ⇒ Piece
A new instance of Piece.
Example:
# Instantiates a new Piece
JustBackgammon::Piece.new(id: 1, owner: 1)
22 23 24 25 |
# File 'lib/just_backgammon/piece.rb', line 22 def initialize(id: , owner:) @id = id @owner = owner end |
Instance Attribute Details
#id ⇒ Fixnum (readonly)
Returns the identifier of the piece.
28 29 30 |
# File 'lib/just_backgammon/piece.rb', line 28 def id @id end |
#owner ⇒ Fixnum (readonly)
Returns the owner of the piece.
31 32 33 |
# File 'lib/just_backgammon/piece.rb', line 31 def owner @owner end |
Instance Method Details
#as_json ⇒ Hash
A hashed serialized representation of the piece.
36 37 38 |
# File 'lib/just_backgammon/piece.rb', line 36 def as_json { id: id, owner: owner } end |