string-utility 1.0.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -1
  3. data/lib/utils.rb +16 -17
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4a7d6edffa1aff2a4cd0f0db086cf0036dca0bc8
4
- data.tar.gz: cc9b94d9b745e3cda02ddfb77e104e443c33d59a
3
+ metadata.gz: 9f92b1066574eae3c7e4ce1e67373585e0281d66
4
+ data.tar.gz: d8ece5bd0236fd66f7145eacdc7454cba36a458c
5
5
  SHA512:
6
- metadata.gz: f37408adc6b7414c2812780fe7da0f580dbbec1efc0f4148f1901efaf3f1156f14488ba6be811a1193e1525e8c87bfed5d171d38e30386f22e9775ff1b08d672
7
- data.tar.gz: 112f84b0457a14321efb0debbe25a8a4f1c7f86247a63cd91a032d1f5cbbc8a59e6754cffca140b071360822900b1f9371314a3c2f4dc9798c5522234e786ce9
6
+ metadata.gz: 1d898cd1faf347f593f501d4cf0ce6e3a366f8e777c7bf790d7c5c3e3306dbbf0873fa074cc256adc52b2dd03bb4c1a0553d9a26a968106cbe0c5175fb831b06
7
+ data.tar.gz: 7e77a383f86c55df46e4a6e0110860c8cd92faa8d32fec02da30e0babfd85b7f08c3331378ad6d1d4825769735a75c471d431db01ea6d3b44ca0e6efe4e8a821
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
- ## Version 1
2
+ ## Version 2
3
+ ### Version 2.0.0
4
+ * There is no longer an initialize method.
5
+ * separate is now a monkeypatch using the refine keyword.
6
+
3
7
  ### Version 1.0.1
4
8
  * No longer need to create an instance of StringUtility. Not really sure why I made that the case in the first place.
5
9
  ### Version 1.0.0
data/lib/utils.rb CHANGED
@@ -1,21 +1,20 @@
1
- class StringUtility
1
+ module StringUtility
2
2
 
3
- # Creates a new instance of the StringUtility class
4
- def initialize; end
5
-
6
- # Separates the string by another string. Useful for converting integers into human-readable numbers.
7
- # @param string [String] The string to separate.
8
- # @param count [Int] The number of integers to separate by. Defaults to 3.
9
- # @param separator [String] The string to use as a separator. Can only be 1 character long. Will use the first character if it is greater than 1 character long. Defaults to a comma.
10
- # @return [String] Formatted version of the provided string.
11
- def self.separate_with(string, count = 3, separator = ',')
12
- if separator.length > 1
13
- separator = separator[0]
3
+ refine String do
4
+ # Separates the string by another string. Useful for converting integers into human-readable numbers.
5
+ # @param count [Int] The number of integers to separate by. Defaults to 3.
6
+ # @param separator [String] The string to use as a separator. Can only be 1 character long. Will use the first character if it is greater than 1 character long. Defaults to a comma.
7
+ # @return [String] Formatted version of the provided string.
8
+ def separate(count = 3, separator = ',')
9
+ if separator.length > 1
10
+ separator = separator[0]
11
+ end
12
+ string = self
13
+ string = string.reverse
14
+ array = string.scan(/.{1,#{count}}/)
15
+ string = array.join(separator)
16
+ string = string.reverse
17
+ return string
14
18
  end
15
- string = string.reverse!
16
- array = string.scan(/.{1,#{count}}/)
17
- string = array.join(separator)
18
- string = string.reverse!
19
- return string
20
19
  end
21
20
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: string-utility
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eli Foster