Sha256: 5132c91142ed9f46a6390bf00fb54060886a87fad8d1a0c00185426289b57965

Contents?: true

Size: 874 Bytes

Versions: 1

Compression:

Stored size: 874 Bytes

Contents

require 'just_backgammon/common'

module JustBackgammon

  # = Piece
  #
  # A piece owned by a player that moves around the board.
  class Piece
    extend Common

    # A new instance of Piece.
    #
    # @param [Fixnum] id
    #   The identifier of the piece.
    #
    # @param [Fixnum] player_number
    #   The owner of the piece.
    #
    # ==== Example:
    #   # Instantiates a new Piece
    #   JustBackgammon::Piece.new(id: 1, player_number: 1)
    def initialize(id: , player_number:)
      @id = id
      @player_number = player_number
    end

    # @return [Fixnum] the identifier of the piece.
    attr_reader :id

    # @return [Fixnum] the owner of the piece
    attr_reader :player_number

    # A hashed serialized representation of the piece.
    #
    # @return [Hash]
    def as_json
      { id: id, player_number: player_number }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
just_backgammon-1.1.0 lib/just_backgammon/piece.rb