lib/just_backgammon/piece.rb in just_backgammon-0.2.0 vs lib/just_backgammon/piece.rb in just_backgammon-1.0.0
- old
+ new
@@ -8,26 +8,33 @@
class Piece
extend Common
# A new instance of Piece.
#
+ # @param [Fixnum] id
+ # The identifier of the piece.
+ #
# @param [Fixnum] owner
# The owner of the piece.
#
# ==== Example:
# # Instantiates a new Piece
- # JustBackgammon::Piece.new(1)
- def initialize(owner:)
+ # JustBackgammon::Piece.new(id: 1, owner: 1)
+ def initialize(id: , owner:)
+ @id = id
@owner = owner
end
+ # @return [Fixnum] the identifier of the piece.
+ attr_reader :id
+
# @return [Fixnum] the owner of the piece
attr_reader :owner
# A hashed serialized representation of the piece.
#
# @return [Hash]
def as_json
- { owner: owner }
+ { id: id, owner: owner }
end
end
end
\ No newline at end of file