Sha256: 342615d7ebcf5c7582453c7f5eb0736437cd6eafdc783e9d9d6721f1964e94f7

Contents?: true

Size: 788 Bytes

Versions: 5

Compression:

Stored size: 788 Bytes

Contents

# frozen_string_literal: true

module Basketball
  module Org
    # Base class describing a player.
    # A consumer application should extend these specific to their specific sports traits.
    class Player < Entity
      attr_reader :overall, :position, :first_name, :last_name

      def initialize(id:, overall: 0, position: nil, first_name: '', last_name: '')
        super(id)

        raise ArgumentError, 'position is required' unless position

        @overall    = overall
        @position   = position
        @first_name = first_name
        @last_name  = last_name

        freeze
      end

      def full_name
        "#{first_name} #{last_name}".strip
      end

      def to_s
        "[#{super}] #{full_name} (#{position}) #{overall}".strip
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
basketball-0.0.22 lib/basketball/org/player.rb
basketball-0.0.21 lib/basketball/org/player.rb
basketball-0.0.20 lib/basketball/org/player.rb
basketball-0.0.19 lib/basketball/org/player.rb
basketball-0.0.18 lib/basketball/org/player.rb