Sha256: 45d7a2a62119076089855528545f089104457fb4a39a66870bbe5b4419be1364

Contents?: true

Size: 442 Bytes

Versions: 2

Compression:

Stored size: 442 Bytes

Contents

# frozen_string_literal: true

class Guess < BaseClass
  VALID_GUESS_LENGTH = 4
  VALID_GUESS_RANGE = ('0'..'6').freeze

  attr_accessor :number
  attr_reader :errors

  def initialize(guess)
    @number = guess
    @errors = []
  end

  def validate
    @errors << 'error_number_length' unless check_length?(@number, VALID_GUESS_LENGTH)
    @errors << 'error_number_digit' unless check_number_in_range?(@number, VALID_GUESS_RANGE)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
codebreaker_gapdn-0.1.1 lib/entities/guess.rb
codebreaker_gapdn-0.1.0 lib/entities/guess.rb