truncate 0.0.1 → 0.0.2

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 (2) hide show
  1. data/lib/truncate.rb +4 -1
  2. metadata +1 -1
data/lib/truncate.rb CHANGED
@@ -11,7 +11,10 @@ class String
11
11
  def words(num, omit = "...")
12
12
  text = self.dup
13
13
  array = text.split(" ")
14
- array[0..num-1].join(" ") + omit
14
+ if array.length > num
15
+ text = array[0..num-1].join(" ") + omit
16
+ end
17
+ text
15
18
  end
16
19
 
17
20
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: truncate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: