RubyGems
npm
Organizations
Log in
Sign up
RubyGems
truncate
Versions diffs
0.0.1 → 0.0.2
truncate 0.0.1 → 0.0.2
Sign up to get
free
protection for your applications and to get access to all the features.
Files changed (2)
hide
show
data/lib/truncate.rb
+4
-1
metadata
+1
-1
data/lib/truncate.rb
CHANGED
Viewed
@@ -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
Viewed
@@ -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: