string-utility 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ad9a5ec9570803ab007444736656b204f3a0464b
4
+ data.tar.gz: 5d6e5f984a218af1c45d5fbc6d848442408aa6b8
5
+ SHA512:
6
+ metadata.gz: 5e909a2bc0d719cb233bb261d72e4437b2dcab9dbf0419c3b46012c61b6bd287e1ff1598fc93530b27bf27aa2f83f54991dad774579c7dcb475a918707d0b209
7
+ data.tar.gz: cabb063efab640757a281d4341cede1775137931a9aa69e3a2f59559fdd21d18a061173a99af1046d5bc9c181d1e7f9b76c47f4a1550e1b87b86404caae03f90
data/CHANGELOG.md ADDED
@@ -0,0 +1,4 @@
1
+ # Changelog
2
+ ## Version 1
3
+ ### Version 1.0.0
4
+ * Initial version. Currently only includes separate_with.
@@ -0,0 +1 @@
1
+ require_relative 'utils'
data/lib/utils.rb ADDED
@@ -0,0 +1,21 @@
1
+ class StringUtility
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 separate_with(string, count = 3, separator = ',')
12
+ if separator.length > 1
13
+ separator = separator[0]
14
+ end
15
+ string = string.reverse!
16
+ array = string.scan(/.{1,#{count}}/)
17
+ string = array.join(separator)
18
+ string = string.reverse!
19
+ return string
20
+ end
21
+ end
metadata ADDED
@@ -0,0 +1,48 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: string-utility
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Eli Foster
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-10-01 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: |2
14
+ Some simple but handy methods to interact with string objects.
15
+ email: elifosterwy@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - CHANGELOG.md
21
+ - lib/string-utility.rb
22
+ - lib/utils.rb
23
+ homepage: https://github.com/elifoster/string-utility-ruby
24
+ licenses:
25
+ - CC-BY-NC-ND-4.0
26
+ metadata:
27
+ issue_tracker: https://github.com/elifoster/string-utility-ruby/issues
28
+ post_install_message:
29
+ rdoc_options: []
30
+ require_paths:
31
+ - lib
32
+ required_ruby_version: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: '2.0'
37
+ required_rubygems_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ requirements: []
43
+ rubyforge_project:
44
+ rubygems_version: 2.4.5.1
45
+ signing_key:
46
+ specification_version: 4
47
+ summary: Provides some basic utilities for interacting with Strings
48
+ test_files: []