stringutilities 0.0.3 → 0.0.4
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 +13 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c2f9cbeb49d03f1e1579b1fe1027359fb65af25
|
4
|
+
data.tar.gz: f0a72549e26edefb3fa210e10cd734c6f4994eb5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26ec2931819547deba3dc5c0d3e5dc5616183d3e1cc3881e0cb74f5eef6bca52a6804b781ce8a1b96044677b75afb28c51f1715bd8fb169f3360187181634664
|
7
|
+
data.tar.gz: 8d012ebd8053b5398674ecd4209dcbd8d4aba8bc4f2b67ccd4c797287fa45e5647655fff0ac96fa921122cd857d36f1a54dee6b6f71c468829071c13f20781fc
|
data/lib/main.rb
CHANGED
@@ -1,4 +1,16 @@
|
|
1
1
|
class String
|
2
|
+
#Returns a new string with word appended to self.
|
3
|
+
def append_word(word)
|
4
|
+
copy = self
|
5
|
+
copy.concat(' ') unless copy.end_with?(' ')
|
6
|
+
copy.concat(word)
|
7
|
+
return copy
|
8
|
+
end
|
9
|
+
#Appends the word to self.
|
10
|
+
def append_word!(word)
|
11
|
+
self.concat(' ') unless self.end_with?(' ')
|
12
|
+
self.concat(word)
|
13
|
+
end
|
2
14
|
#Returns the longest word in self.
|
3
15
|
def longest_word()
|
4
16
|
longest = ""
|
@@ -41,6 +53,7 @@ class String
|
|
41
53
|
self[index1] = self[index2]
|
42
54
|
self[index2] = tempvar
|
43
55
|
end
|
56
|
+
#Returns the number of times the word occurs.
|
44
57
|
def word_occurrences(word)
|
45
58
|
number_occurrences = 0
|
46
59
|
self.words().each() do |w|
|