stringutilities 0.0.2 → 0.0.3

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/main.rb +9 -0
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 45e438f4f5bb37922529d0ec5d7a11961c332100
4
- data.tar.gz: 68cd2398c9c1041ab163e3c96453c1a4c5174252
3
+ metadata.gz: c2781859f62a4ccb017fc1d4c3676ef72293853e
4
+ data.tar.gz: 12a31b93a69c510eedfad4771ef43a4e18283ed0
5
5
  SHA512:
6
- metadata.gz: 91fd1227178ad7f1740eab7a8b280f0d015cae807b7f2ceb3221bcccca9af07aea436c129e4dfd2039575b72833c1be8ff82dfd1f70ec534a7f9edc67ed73315
7
- data.tar.gz: 9bd2b457d64050a2f1ad521b425e1c2c505c60b67128b7ac77a169254ed07a6f906d96bf0b3b231418b6924bcca5f5a5556794059da40d353a7f51aa137ad783
6
+ metadata.gz: 728244ae5ca717708d462bf327854acb3dafd9131405118f56736b2219de623c2f11bc4688260bd06355000364e8ab14c7824f2d2ae1d04931cbd8fc2ffc9610
7
+ data.tar.gz: 32a2ed20caa684090b78bd829bfe4e204fe2ac8d3dcf5c2e7bae4b66f91f6a5e77de92757ec0ce02b277a82bbc8b2ae77a6909d72df5047c42d4595bdeb2faae
data/lib/main.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  class String
2
+ #Returns the longest word in self.
2
3
  def longest_word()
3
4
  longest = ""
4
5
  for word in self.words()
@@ -8,6 +9,7 @@ class String
8
9
  end
9
10
  return longest
10
11
  end
12
+ #Returns the shortest word in self.
11
13
  def shortest_word()
12
14
  shortest = self.words()[0]
13
15
  for word in self.words()
@@ -39,6 +41,13 @@ class String
39
41
  self[index1] = self[index2]
40
42
  self[index2] = tempvar
41
43
  end
44
+ def word_occurrences(word)
45
+ number_occurrences = 0
46
+ self.words().each() do |w|
47
+ number_occurrences += 1 if w == word
48
+ end
49
+ return number_occurrences
50
+ end
42
51
  #Returns all the words in the string.
43
52
  def words()
44
53
  return self.split(' ')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stringutilities
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - SugarRush