aboutarray 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/aboutarray.rb +34 -0
  3. metadata +44 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 31992555ea9e6d72ad3860129dfa55e4aaf9afd265f51094cbb400f1e677a048
4
+ data.tar.gz: 11eb34677264ac9c600dac1c3072d35b1ace21bba6b5660925c9dc5c5ad73cd9
5
+ SHA512:
6
+ metadata.gz: ef3233f7a3f2cc2135fb4cc5f0c952bbcb7285ab1e24de149af741f8eadf5ae8497f2d44802235416cde8400d14ea12a39f2ab18340af8a16181a168de556534
7
+ data.tar.gz: 5bcacd5f0bbb2bfc78e7ba8c95bdb3e189ab624a95f3ccba0d61bbae19cfee57d2b2439cc7cc98f5f1d603eac058353e7e69f1404e1f336e9f023b93df596b70
data/lib/aboutarray.rb ADDED
@@ -0,0 +1,34 @@
1
+ class Trialgemgue
2
+ def self.all_duplicate(arr)
3
+ raise 'Type Error' unless arr.instance_of? Array
4
+
5
+ @arr = arr
6
+ @arr.sort!
7
+ report = []
8
+ duplicate_item_list = arr.uniq # [1,1,2] [1,2]
9
+ duplicate_item_list.each do |candidate|
10
+ duplicate_item_count = find_all_duplicate(candidate)
11
+ next unless duplicate_item_count > 1
12
+
13
+ report << [candidate, duplicate_item_count]
14
+ end
15
+
16
+ return reporting(report)
17
+
18
+ end
19
+
20
+ private
21
+
22
+ def self.find_all_duplicate(candidate)
23
+ match_items = 0
24
+ @arr.each do |item|
25
+ match_items += 1 unless item != candidate
26
+ end
27
+
28
+ return match_items
29
+ end
30
+
31
+ def self.reporting(duplicate_item_list)
32
+ duplicate_item_list.to_h
33
+ end
34
+ end
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: aboutarray
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Rendytio
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-06-22 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: this gem will try to reduce the use of lines of your code when you are
14
+ trying to find how many values are the same in an array
15
+ email: rendytio.arifian@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/aboutarray.rb
21
+ homepage: https://rubygems.org/gems/aboutarray
22
+ licenses:
23
+ - MIT
24
+ metadata: {}
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ requirements: []
40
+ rubygems_version: 3.2.15
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: Gem about array
44
+ test_files: []