Sha256: b4374e420e785de57fb8ac73fa8c65f21c6afb186d147a1f3651041f5810d839
Contents?: true
Size: 1 KB
Versions: 6
Compression:
Stored size: 1 KB
Contents
# frozen_string_literal: true module Basketball module Drafting class Player < Entity STAR_THRESHOLD = 75 OVERALL_STAR_INDICATOR = '⭐' private_constant :STAR_THRESHOLD, :OVERALL_STAR_INDICATOR attr_reader :first_name, :last_name, :position, :overall def initialize(id:, position:, first_name: '', last_name: '', overall: 0) super(id) raise ArgumentError, 'position is required' unless position @first_name = first_name.to_s @last_name = last_name.to_s @position = position @overall = overall.to_i freeze end def full_name "#{first_name.strip} #{last_name.strip}".strip end def to_s "[#{super}] #{full_name} (#{position}) #{overall} #{star_indicators.join(', ')}".strip end private def star_indicators [].tap do |indicators| indicators << OVERALL_STAR_INDICATOR if overall >= STAR_THRESHOLD end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems