new_super_codebreaker_2021 0.4.4 → 0.4.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 310473574af90875c8838fadf808a3293e7667f1452c90b28618906f20f4d43d
4
- data.tar.gz: 7df218a49809e4811ed1adc27093fc4bc9a7353c23b82bf81160421989b7c5a3
3
+ metadata.gz: 26b37e2d9e16f4e0976f62163e3e1c69eb224495de4ca2a845987672de45132d
4
+ data.tar.gz: b9acc9f22a9b6f8a425be538b9685ee5feb9d7a049275b2639c7246a69450ec9
5
5
  SHA512:
6
- metadata.gz: 690e606a26291342c8fe91387db9d467403e179bbed937f9bc0ad1ae11cb9f7a7970d51ea2295a836910a500a7b73608f51cbbaab24190f2f4fff58d5cd84f07
7
- data.tar.gz: 7b89164a1189f3a81f360fec5cf5fe839708c314b9497e1dbd307b12f607be24e083fa4a78f3790b6b225936fe0e3d925a4bd5e39756cc44bf5e02b21c3f73ea
6
+ metadata.gz: dd7c966984d2b7257492611fe2018dfd4b5dc2541eb34213783196aeadd73dac063209ccbd37a20aadee711b2a8804622a1ce7fa8a3d813d47b3a83139fe498b
7
+ data.tar.gz: 7f11831e008fb7463258b792799fa787a23735138cbbea0470f61e4210a18e9bcda3fdb740473c828514e50ebf6bd7c065a153b307aa11f62b127e88dab5190f
data/lib/loader.rb ADDED
@@ -0,0 +1,8 @@
1
+ require 'yaml'
2
+ require_relative 'new_super_codebreaker_2021/user'
3
+ require_relative 'new_super_codebreaker_2021/show_content'
4
+ require_relative 'new_super_codebreaker_2021/db_methods'
5
+ require_relative 'new_super_codebreaker_2021/validate'
6
+ require_relative 'new_super_codebreaker_2021/new_super_codebreaker_2021'
7
+ require_relative 'new_super_codebreaker_2021/game'
8
+ require_relative 'new_super_codebreaker_2021/version'
@@ -0,0 +1,17 @@
1
+ module NewSuperCodebreaker2021
2
+ module DBMethods
3
+ def save(user, file)
4
+ rating = load_file(file)
5
+ rating.push(user)
6
+ File.open(file, 'w') do |filename|
7
+ YAML.dump(rating, filename)
8
+ end
9
+ end
10
+
11
+ def load_file(file)
12
+ YAML.load_file(file)
13
+ rescue Errno::ENOENT
14
+ []
15
+ end
16
+ end
17
+ end
@@ -1,16 +1,16 @@
1
- require 'yaml'
2
- require_relative 'validate'
3
- require_relative 'show_content'
4
- require_relative 'db_methods'
5
- require_relative 'user'
1
+ require_relative '../loader'
2
+
6
3
  module NewSuperCodebreaker2021
7
4
  class Game
8
- include Validate
9
- include ShowContent
10
5
  include DBMethods
6
+ include ShowContent
7
+ include Validate
8
+
9
+ attr_reader :code
11
10
 
12
11
  def initialize
13
12
  @code = generate_code
13
+ @code_copy = @code.dup
14
14
  end
15
15
 
16
16
  GUESS_COMMANDS = %i[hint rules exit].freeze
@@ -36,23 +36,18 @@ module NewSuperCodebreaker2021
36
36
  end
37
37
 
38
38
  def user_guess(code)
39
- if code.to_i != 0
40
- validate_user_code(code)
41
- elsif GUESS_COMMANDS.include?(code.to_sym)
42
- code.to_sym
43
- else false
44
- end
39
+ return validate_user_code(code) unless code.to_i.zero?
40
+
41
+ symbol_code = code.to_sym
42
+ GUESS_COMMANDS.include?(symbol_code) ? symbol_code : nil
45
43
  end
46
44
 
47
45
  def take_hint(user, used_hints)
48
- code_copy = @code.dup
49
- if user.hints_total > user.hints_used
50
- user.hints_used += 1
51
- used_hints.each { |hint| code_copy.delete(hint) }
52
- code_copy.sample
53
- else
54
- false
55
- end
46
+ return unless user.hints_total > user.hints_used
47
+
48
+ user.hints_used += 1
49
+ used_hints.each { |hint| @code_copy.delete(hint) }
50
+ @code_copy.sample
56
51
  end
57
52
 
58
53
  def after_game_commands(command)
@@ -64,27 +59,34 @@ module NewSuperCodebreaker2021
64
59
  end
65
60
 
66
61
  def compare_codes(user_code)
67
- matches, u_char = number_on_right_place(user_code)
68
- number_in_secret_code(user_code, matches, u_char)
62
+ matches, user_code, code_copy = number_on_right_place(user_code)
63
+ number_in_secret_code(user_code, matches, code_copy)
69
64
  end
70
65
 
71
66
  private
72
67
 
73
68
  def number_on_right_place(user_code)
69
+ code_copy = @code.dup
74
70
  matches = []
75
- u_char = []
76
71
  user_code.each_index do |i|
77
- if @code[i] == user_code[i]
78
- matches.unshift('+')
79
- u_char << user_code[i]
80
- end
72
+ next unless @code[i] == user_code[i]
73
+
74
+ matches.unshift('+')
75
+ user_code[i] = nil
76
+ code_copy[i] = false
81
77
  end
82
- [matches, u_char]
78
+ [matches, user_code, code_copy]
83
79
  end
84
80
 
85
- def number_in_secret_code(user_code, matches, u_char)
81
+ def number_in_secret_code(user_code, matches, code_copy)
82
+ amount_numbers_in_secret_code = Hash.new(0)
83
+ amount_numbers_in_user_code = Hash.new(0)
84
+ code_copy.each { |number| amount_numbers_in_secret_code[number] += 1 }
86
85
  user_code.each do |element|
87
- matches.push('-') if @code.include?(element) && !u_char.include?(element)
86
+ if code_copy.include?(element) && amount_numbers_in_user_code[element] < amount_numbers_in_secret_code[element]
87
+ matches.push('-')
88
+ amount_numbers_in_user_code[element] += 1
89
+ end
88
90
  end
89
91
  matches
90
92
  end
@@ -0,0 +1,10 @@
1
+ require 'game'
2
+ require 'user'
3
+ require 'show_content'
4
+ require 'validate'
5
+ require 'db_methods'
6
+ require_relative 'version'
7
+
8
+ module NewSuperCodebreaker2021
9
+ class Error < StandardError; end
10
+ end
@@ -0,0 +1,10 @@
1
+ module NewSuperCodebreaker2021
2
+ module ShowContent
3
+ def show_stats(file)
4
+ data = YAML.load_file(file) || []
5
+ data.sort_by! { |game| [-game.difficulty, game.attempts_used, game.hints_used] }
6
+ rescue Errno::ENOENT
7
+ []
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,28 @@
1
+ module NewSuperCodebreaker2021
2
+ class User
3
+ attr_reader :name, :difficulty, :hints_total, :attempts_total
4
+ attr_accessor :hints_used, :attempts_used
5
+
6
+ DIFFICULTY = {
7
+ easy: { attempts: 15, hints: 2 },
8
+ medium: { attempts: 10, hints: 1 },
9
+ hell: { attempts: 5, hints: 1 }
10
+ }.freeze
11
+
12
+ def initialize(name, difficulty)
13
+ @name = name
14
+ @difficulty = difficulty
15
+ @hints_used = 0
16
+ @attempts_used = 0
17
+ set_total_fields
18
+ end
19
+
20
+ private
21
+
22
+ def set_total_fields
23
+ difficulty = DIFFICULTY.keys[@difficulty]
24
+ @hints_total = DIFFICULTY[difficulty][:hints]
25
+ @attempts_total = DIFFICULTY[difficulty][:attempts]
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,50 @@
1
+ module NewSuperCodebreaker2021
2
+ module Validate
3
+ def validate_name(name)
4
+ name if valid_name?(name)
5
+ end
6
+
7
+ def validate_user_code(us_code)
8
+ arr_code = split_to_integer_array(us_code)
9
+ return unless valid_number?(arr_code)
10
+
11
+ arr_code
12
+ end
13
+
14
+ def check_input(input, command_list)
15
+ return unless valid_input?(input, command_list)
16
+
17
+ input.to_sym
18
+ end
19
+
20
+ private
21
+
22
+ def valid_input?(input, command_list)
23
+ input.to_i.zero? && command_list.include?(input.to_sym)
24
+ end
25
+
26
+ def valid_number?(arr_code)
27
+ arr_code && check_code_length?(arr_code) && check_numbers?(arr_code)
28
+ end
29
+
30
+ def split_to_integer_array(code)
31
+ code.chars.map!(&:to_i) if integer?(code)
32
+ end
33
+
34
+ def integer?(code)
35
+ code.to_i.to_s == code
36
+ end
37
+
38
+ def check_code_length?(code)
39
+ code.length == 4
40
+ end
41
+
42
+ def check_numbers?(code)
43
+ code.all? { |value| value.between?(1, 6) }
44
+ end
45
+
46
+ def valid_name?(name)
47
+ name.length >= 3 && name.length <= 20
48
+ end
49
+ end
50
+ end
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  module NewSuperCodebreaker2021
4
- VERSION = '0.4.4'
2
+ VERSION = '0.4.8'.freeze
5
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: new_super_codebreaker_2021
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 0.4.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nazar Dakhno
8
8
  autorequire:
9
- bindir: bin
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-10 00:00:00.000000000 Z
11
+ date: 2021-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fasterer
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.9.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: ffaker
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 2.19.0
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 2.19.0
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rake
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -101,21 +115,15 @@ executables: []
101
115
  extensions: []
102
116
  extra_rdoc_files: []
103
117
  files:
104
- - CHANGELOG.md
105
- - CODE_OF_CONDUCT.md
106
- - Gemfile
107
- - Gemfile.lock
108
118
  - README.md
109
- - Rakefile
110
- - bin/console
111
- - bin/setup
112
- - lib/db_methods.rb
113
- - lib/game.rb
114
- - lib/new_super_codebreaker_2021.rb
119
+ - lib/loader.rb
120
+ - lib/new_super_codebreaker_2021/db_methods.rb
121
+ - lib/new_super_codebreaker_2021/game.rb
122
+ - lib/new_super_codebreaker_2021/new_super_codebreaker_2021.rb
123
+ - lib/new_super_codebreaker_2021/show_content.rb
124
+ - lib/new_super_codebreaker_2021/user.rb
125
+ - lib/new_super_codebreaker_2021/validate.rb
115
126
  - lib/new_super_codebreaker_2021/version.rb
116
- - lib/show_content.rb
117
- - lib/user.rb
118
- - lib/validate.rb
119
127
  homepage: https://rubygems.org/gems/new_super_codebreaker_2021
120
128
  licenses:
121
129
  - MIT
@@ -123,7 +131,7 @@ metadata: {}
123
131
  post_install_message:
124
132
  rdoc_options: []
125
133
  require_paths:
126
- - lib
134
+ - lib/new_super_codebreaker_2021
127
135
  required_ruby_version: !ruby/object:Gem::Requirement
128
136
  requirements:
129
137
  - - ">="
data/CHANGELOG.md DELETED
@@ -1,5 +0,0 @@
1
- ## [Unreleased]
2
-
3
- ## [0.1.0] - 2021-08-17
4
-
5
- - Initial release
data/CODE_OF_CONDUCT.md DELETED
@@ -1,84 +0,0 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
-
7
- We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
-
9
- ## Our Standards
10
-
11
- Examples of behavior that contributes to a positive environment for our community include:
12
-
13
- * Demonstrating empathy and kindness toward other people
14
- * Being respectful of differing opinions, viewpoints, and experiences
15
- * Giving and gracefully accepting constructive feedback
16
- * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
- * Focusing on what is best not just for us as individuals, but for the overall community
18
-
19
- Examples of unacceptable behavior include:
20
-
21
- * The use of sexualized language or imagery, and sexual attention or
22
- advances of any kind
23
- * Trolling, insulting or derogatory comments, and personal or political attacks
24
- * Public or private harassment
25
- * Publishing others' private information, such as a physical or email
26
- address, without their explicit permission
27
- * Other conduct which could reasonably be considered inappropriate in a
28
- professional setting
29
-
30
- ## Enforcement Responsibilities
31
-
32
- Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
-
34
- Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
-
36
- ## Scope
37
-
38
- This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
-
40
- ## Enforcement
41
-
42
- Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at dakhnonazar@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
-
44
- All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
-
46
- ## Enforcement Guidelines
47
-
48
- Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
-
50
- ### 1. Correction
51
-
52
- **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
-
54
- **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
-
56
- ### 2. Warning
57
-
58
- **Community Impact**: A violation through a single incident or series of actions.
59
-
60
- **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
-
62
- ### 3. Temporary Ban
63
-
64
- **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
-
66
- **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
-
68
- ### 4. Permanent Ban
69
-
70
- **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
-
72
- **Consequence**: A permanent ban from any sort of public interaction within the community.
73
-
74
- ## Attribution
75
-
76
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
- available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
-
79
- Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
-
81
- [homepage]: https://www.contributor-covenant.org
82
-
83
- For answers to common questions about this code of conduct, see the FAQ at
84
- https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile DELETED
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source 'https://rubygems.org'
4
-
5
- # Specify your gem's dependencies in new_super_codebreaker_2021.gemspec
6
- gemspec
data/Gemfile.lock DELETED
@@ -1,71 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- new_super_codebreaker_2021 (0.1.0)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- ast (2.4.2)
10
- colorize (0.8.1)
11
- diff-lcs (1.4.4)
12
- docile (1.4.0)
13
- fasterer (0.9.0)
14
- colorize (~> 0.7)
15
- ruby_parser (>= 3.14.1)
16
- parallel (1.20.1)
17
- parser (3.0.2.0)
18
- ast (~> 2.4.1)
19
- rainbow (3.0.0)
20
- rake (13.0.6)
21
- regexp_parser (2.1.1)
22
- rexml (3.2.5)
23
- rspec (3.10.0)
24
- rspec-core (~> 3.10.0)
25
- rspec-expectations (~> 3.10.0)
26
- rspec-mocks (~> 3.10.0)
27
- rspec-core (3.10.1)
28
- rspec-support (~> 3.10.0)
29
- rspec-expectations (3.10.1)
30
- diff-lcs (>= 1.2.0, < 2.0)
31
- rspec-support (~> 3.10.0)
32
- rspec-mocks (3.10.2)
33
- diff-lcs (>= 1.2.0, < 2.0)
34
- rspec-support (~> 3.10.0)
35
- rspec-support (3.10.2)
36
- rubocop (1.19.1)
37
- parallel (~> 1.10)
38
- parser (>= 3.0.0.0)
39
- rainbow (>= 2.2.2, < 4.0)
40
- regexp_parser (>= 1.8, < 3.0)
41
- rexml
42
- rubocop-ast (>= 1.9.1, < 2.0)
43
- ruby-progressbar (~> 1.7)
44
- unicode-display_width (>= 1.4.0, < 3.0)
45
- rubocop-ast (1.10.0)
46
- parser (>= 3.0.1.1)
47
- ruby-progressbar (1.11.0)
48
- ruby_parser (3.17.0)
49
- sexp_processor (~> 4.15, >= 4.15.1)
50
- sexp_processor (4.15.3)
51
- simplecov (0.21.2)
52
- docile (~> 1.1)
53
- simplecov-html (~> 0.11)
54
- simplecov_json_formatter (~> 0.1)
55
- simplecov-html (0.12.3)
56
- simplecov_json_formatter (0.1.3)
57
- unicode-display_width (2.0.0)
58
-
59
- PLATFORMS
60
- x86_64-linux
61
-
62
- DEPENDENCIES
63
- fasterer (~> 0.9.0)
64
- new_super_codebreaker_2021!
65
- rake (~> 13.0)
66
- rspec (~> 3.10.0)
67
- rubocop (~> 1.7)
68
- simplecov
69
-
70
- BUNDLED WITH
71
- 2.2.26
data/Rakefile DELETED
@@ -1,9 +0,0 @@
1
- require 'bundler/gem_tasks'
2
- require 'rubocop/rake_task'
3
-
4
- begin
5
- require 'rspec/core/rake_task'
6
- RSpec::Core::RakeTask.new(:spec)
7
- rescue LoadError
8
- # Ignored
9
- end
data/bin/console DELETED
@@ -1,15 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require 'bundler/setup'
5
- require 'new_super_codebreaker_2021'
6
-
7
- # You can add fixtures and/or initialization code here to make experimenting
8
- # with your gem easier. You can also use a different console, if you like.
9
-
10
- # (If you use this, don't forget to add pry to your Gemfile!)
11
- # require "pry"
12
- # Pry.start
13
-
14
- require 'irb'
15
- IRB.start(__FILE__)
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
data/lib/db_methods.rb DELETED
@@ -1,15 +0,0 @@
1
- module DBMethods
2
- def save(user, file)
3
- rating = load_file(file)
4
- rating.push(user)
5
- File.open(file, 'w') do |filename|
6
- YAML.dump(rating, filename)
7
- end
8
- end
9
-
10
- def load_file(file)
11
- YAML.load_file(file)
12
- rescue Errno::ENOENT
13
- []
14
- end
15
- end
@@ -1,6 +0,0 @@
1
- require_relative 'new_super_codebreaker_2021/version'
2
- require 'game'
3
-
4
- module NewSuperCodebreaker2021
5
- class Error < StandardError; end
6
- end
data/lib/show_content.rb DELETED
@@ -1,16 +0,0 @@
1
- require 'terminal-table'
2
-
3
- module ShowContent
4
- DIFFICULTY = {
5
- easy: { attempts: 15, hints: 2 },
6
- medium: { attempts: 10, hints: 1 },
7
- hell: { attempts: 5, hints: 1 }
8
- }.freeze
9
-
10
- def show_stats(file)
11
- data = YAML.load_file(file) || []
12
- data.sort_by(&:hints_used).sort_by(&:attempts_used).sort_by { |game| -game.difficulty }
13
- rescue Errno::ENOENT
14
- []
15
- end
16
- end
data/lib/user.rb DELETED
@@ -1,32 +0,0 @@
1
- class User
2
- attr_reader :name, :difficulty, :hints_total, :attempts_total
3
- attr_accessor :hints_used, :attempts_used
4
-
5
- def initialize(name, difficulty)
6
- @name = name
7
- @difficulty = difficulty
8
- @hints_used = 0
9
- @attempts_used = 0
10
- check_difficulty(difficulty)
11
- end
12
-
13
- private
14
-
15
- def check_difficulty(difficulty)
16
- case difficulty
17
- when 0
18
- set_total_fields(2, 15)
19
- when 1
20
- set_total_fields(1, 10)
21
- when 2
22
- set_total_fields(1, 5)
23
- else
24
- false
25
- end
26
- end
27
-
28
- def set_total_fields(hints_total, attempts_total)
29
- @hints_total = hints_total
30
- @attempts_total = attempts_total
31
- end
32
- end
data/lib/validate.rb DELETED
@@ -1,50 +0,0 @@
1
- module Validate
2
- def validate_name(name)
3
- if name.length >= 3 && name.length <= 20
4
- name
5
- else
6
- false
7
- end
8
- end
9
-
10
- def validate_user_code(us_code)
11
- arr_code = check_splitting(us_code)
12
- if valid_number?(arr_code)
13
- arr_code
14
- else
15
- false
16
- end
17
- end
18
-
19
- def check_input(input, command_list)
20
- if input.to_i.zero? && command_list.include?(input.to_sym)
21
- input.to_sym
22
- else false
23
- end
24
- end
25
-
26
- private
27
-
28
- def valid_number?(arr_code)
29
- arr_code && check_length?(arr_code) && check_numbers?(arr_code)
30
- end
31
-
32
- def check_splitting(code)
33
- code.chars.map!(&:to_i) if integer?(code)
34
- end
35
-
36
- def integer?(code)
37
- code.to_i.to_s == code
38
- end
39
-
40
- def check_length?(code)
41
- code.length == 4
42
- end
43
-
44
- def check_numbers?(code)
45
- code.each do |number|
46
- return if number < 1 || number > 6
47
- end
48
- true
49
- end
50
- end