subvisual-utils 0.3.0 → 0.3.1
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/CHANGELOG.md +7 -0
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/lib/subvisual/string_utils/replace_at.rb +5 -1
- data/lib/subvisual/utils.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 023b58b199b9147c577c5d4cb7ec7a8229db991e60ee67b88c5b837c1e73f6fd
|
4
|
+
data.tar.gz: 5b450502ac3aa6cdc8611964e8fe8a6aca2c99d9b91a27b20f96dc302fb9235f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34c6f7aed372440c0b2a5a4947e8f5083d5c79dfdeb3b607017d2042d1f68266eef1b22996f22b7beb9610ad04f6c6a709fff3c5953c89481fd287fb29d80cf3
|
7
|
+
data.tar.gz: f17e7e041106d725670b770923578f0f044a3b425292e53ce001dac19c110a2234bca1ba0db88c162a7c0c94f6286b5c0fb31c2c35887bb262980a2460e75acc
|
data/CHANGELOG.md
CHANGED
@@ -11,6 +11,13 @@ and this project adheres to [Semantic Versioning].
|
|
11
11
|
Unreleased
|
12
12
|
----------
|
13
13
|
|
14
|
+
- Changed `StringUtils.replace_at(string, index, replacement)` to accept a list
|
15
|
+
of indices to replace.
|
16
|
+
|
17
|
+
|
18
|
+
v0.3.0 - 2020-05-07
|
19
|
+
-------------------
|
20
|
+
|
14
21
|
- Added `StringUtils.replace_at(string, index, replacement)`.
|
15
22
|
|
16
23
|
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -57,7 +57,7 @@ Subvisual::MathUtils.least_common_denominator(21, 6) # => 42
|
|
57
57
|
|
58
58
|
### `Subvisual::StringUtils.replace_at(string, index, replacement)`
|
59
59
|
|
60
|
-
Replaces the character at a specific index in a String.
|
60
|
+
Replaces the character at a specific index, or indices, in a String.
|
61
61
|
|
62
62
|
```ruby
|
63
63
|
Subvisual::StringUtils.replace_at("Hello", 1, "a") # => "Hallo"
|
@@ -4,8 +4,12 @@ module Subvisual
|
|
4
4
|
module StringUtils
|
5
5
|
module ReplaceAt
|
6
6
|
def replace_at(string, index, replacement)
|
7
|
+
indices = index.is_a?(Enumerable) ? index : [index]
|
8
|
+
|
7
9
|
string.chars.tap do |characters|
|
8
|
-
|
10
|
+
indices.each do |i|
|
11
|
+
characters[i] = replacement
|
12
|
+
end
|
9
13
|
end.join
|
10
14
|
end
|
11
15
|
end
|
data/lib/subvisual/utils.rb
CHANGED