Sha256: da43250e0b4dee9c65ee34c6a98e25251bdc30284095b632de69c1e55147390c

Contents?: true

Size: 809 Bytes

Versions: 3

Compression:

Stored size: 809 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] owner
    #   The owner of the piece.
    #
    # ==== Example:
    #   # Instantiates a new Piece
    #   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
      { id: id, owner: owner }
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
just_backgammon-1.0.2 lib/just_backgammon/piece.rb
just_backgammon-1.0.1 lib/just_backgammon/piece.rb
just_backgammon-1.0.0 lib/just_backgammon/piece.rb