Sha256: fa1f57ebe5fba789dc1010915c7341aa4f878617c69629eaec3ae88250ca7a14
Contents?: true
Size: 677 Bytes
Versions: 3
Compression:
Stored size: 677 Bytes
Contents
# frozen_string_literal: true module Codebreaker class Guess < ValidatableEntity attr_reader :input, :errors HINT = 'hint' def initialize(input) super() @input = input end def validate return if hint? @errors << I18n.t('invalid.include_error') unless check_numbers?(@input, valid_numbers) @errors << I18n.t('invalid.size_error') unless check_size?(@input, Game::CODE_SIZE) end def as_array_of_numbers @as_array_of_numbers ||= @input.chars.map(&:to_i) end def hint? @input == HINT end private def valid_numbers Game::INCLUDE_IN_GAME_NUMBERS.map(&:to_s) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
codebreaker_Shkidchenko-1.3.0 | lib/app/entities/guess.rb |
codebreaker_Shkidchenko-0.2.0 | lib/app/entities/guess.rb |
codebreaker_Shkidchenko-0.1.0 | lib/app/entities/guess.rb |