Sha256: 57f06b7f43b6332cb5a7ccc3f7654a0d23f06077b64bf12f3533cbc4b18e28d5

Contents?: true

Size: 392 Bytes

Versions: 1

Compression:

Stored size: 392 Bytes

Contents

module Mastermind
  class Game
    class Piece
      COLORS = [:red, :green, :blue, :yellow, :white, :black]

      attr_reader :color

      def initialize(color: COLORS.sample)
        raise ArgumentError.new("Invalid color.") unless COLORS.include?(color)
        @color = color
      end

      def ==(piece)
        piece.is_a?(Piece) && color == piece.color
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mastermind-game-0.0.1 lib/mastermind/game/piece.rb