Sha256: e918de6eed246527fbd34f6b5cc88f614343bdfbd7ad2e2171a3a712f8731cdb
Contents?: true
Size: 1.24 KB
Versions: 1
Compression:
Stored size: 1.24 KB
Contents
# frozen_string_literal: true module CodebrekerManfly class UserStatistics < ValidatableEntity include Validator attr_reader :user, :difficulty, :attempts, :hints, :date def initialize(user:, difficulty:, attempts:, hints:) super() @user = user @difficulty = difficulty @attempts = attempts @hints = hints @date = DateTime.now end private def validate add_error(:user, I18n.t(:unexpected_class_error)) unless valid_class?(CodebrekerManfly::User, user) add_error(:difficulty, I18n.t(:unexpected_class_error)) unless valid_class?(CodebrekerManfly::Difficulty, difficulty) validate_attempts validate_hints end def validate_attempts return add_error(:attempts, I18n.t(:unexpected_class_error)) unless valid_class?(Integer, attempts) add_error(:attempts, I18n.t(:negative_integer_error)) unless valid_non_negative_integer?(attempts) end def validate_hints return add_error(:hints, I18n.t(:unexpected_class_error)) unless valid_class?(Integer, hints) add_error(:hints, I18n.t(:negative_integer_error)) unless valid_non_negative_integer?(hints) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
codebreker_manfly-0.1.2 | lib/codebreker_manfly/entities/user_statistics.rb |