stringutilities 0.0.4 → 0.0.5
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.
- checksums.yaml +4 -4
- data/lib/main.rb +20 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a684f18d98fa055305c51f2234a8589767dd85c
|
4
|
+
data.tar.gz: 745bd2fa0fa784c1ac72aa824ea27ba00ef4b03b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad5675567751c7728628fa419f408bcf6a3bfd7200d796c7e6e82e67fe4900cb4e11c6419b168fd5e5232b6e9caf69df5c21a67d82077d7d6fc8197b3214858e
|
7
|
+
data.tar.gz: 42f4521e77931ed876975ebed9e024804d0d07ca970a8eec9196cc7ea7873780010dfc089f6c9b4cbd5ed8dfae4b386c27b7e8b7ca1b768f41bd093382578bb3
|
data/lib/main.rb
CHANGED
@@ -65,4 +65,24 @@ class String
|
|
65
65
|
def words()
|
66
66
|
return self.split(' ')
|
67
67
|
end
|
68
|
+
#Returns the most common character or characters.
|
69
|
+
def highest_frequency_chars()
|
70
|
+
chars = {}
|
71
|
+
self.chars().each() do |c|
|
72
|
+
if not chars.key?(c)
|
73
|
+
chars[c] = 1
|
74
|
+
else
|
75
|
+
chars[c] += 1
|
76
|
+
end
|
77
|
+
end
|
78
|
+
greatest_value = -1
|
79
|
+
greatest_value_chars = []
|
80
|
+
for char in chars.keys()
|
81
|
+
if chars[char] >= greatest_value
|
82
|
+
greatest_value = chars[char]
|
83
|
+
greatest_value_chars << char
|
84
|
+
end
|
85
|
+
end
|
86
|
+
return greatest_value_chars
|
87
|
+
end
|
68
88
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stringutilities
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SugarRush
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-10-
|
11
|
+
date: 2018-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |-
|
14
14
|
This gem adds several methods to the String class. It will be updated frequently to
|