truncate 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/truncate.rb +5 -5
  2. metadata +2 -2
data/lib/truncate.rb CHANGED
@@ -1,18 +1,18 @@
1
1
  class String
2
2
 
3
- def truncate(length = 20, omit = "...")
3
+ def truncate(length = 20, omis = "...")
4
4
  text = self.dup
5
5
  if text.length > length
6
- text = text[0...length] + omit
6
+ text = text[0...length].strip + omis
7
7
  end
8
8
  text
9
9
  end
10
10
 
11
- def words(num, omit = "...")
11
+ def words(length, omis = "...")
12
12
  text = self.dup
13
13
  array = text.split(" ")
14
- if array.length > num
15
- text = array[0..num-1].join(" ") + omit
14
+ if array.length > length
15
+ text = array[0...length].join(" ") + omis
16
16
  end
17
17
  text
18
18
  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.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-18 00:00:00.000000000 Z
12
+ date: 2013-05-23 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Extends String to truncate by character length or number of words.
15
15
  email: rick.myers@me.com