Sha256: 8a4c595f71f7e38e9682f98166bcab884c734b0577db1e0e0ff3a64267c29786

Contents?: true

Size: 402 Bytes

Versions: 1

Compression:

Stored size: 402 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: #{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.2 lib/mastermind/game/piece.rb