Method: ChefAPI::Util#truncate
- Defined in:
- lib/chef-api/util.rb
#truncate(string, options = {}) ⇒ Object
Truncate the given string to a certain number of characters.
48 49 50 51 52 53 54 55 56 |
# File 'lib/chef-api/util.rb', line 48 def truncate(string, = {}) length = [:length] || 30 if string.length > length string[0..length - 3] + "..." else string end end |