sonic-pi
https://github.com/sonic-pi-net/sonic-pi
C++
Code. Music. Live.
String#truncate
Truncates a given +text+ after a given <tt>length</tt> if +text+ is longer than <tt>length</tt>: 'Once upon a time in a world far far away'.truncate(27) # => "Once upon a time in a wo..." Pass a string or regexp <tt>:separator</tt> to truncate +text+ at a natural break: 'Once upon a time in a world far far away'.truncate(27, separator: ' ') # => "Once upon a time in a..." 'Once upon a time in a world far far away'.truncate(27, separator: /\s/) # => "Once upon a time in a..." The last characters will be replaced with the <tt>:omission</tt> string (defaults to "...") for a total length not exceeding <tt>length</tt>: 'And they found that many people were sleeping better.'.truncate(25, omission: '... (continued)') # => "And they f... (continued)"
Edit
git clone [email protected]:sonic-pi-net/sonic-pi.git
cd sonic-pi
open app/server/ruby/vendor/activesupport-7.0.6/lib/active_support/core_ext/string/filters.rb
Contribute
# Make a new branchgit checkout -b -your-name--update-docs-String-truncate-for-pr
# Commit to gitgit add app/server/ruby/vendor/activesupport-7.0.6/lib/active_support/core_ext/string/filters.rbgit commit -m "better docs for String#truncate"
# Open pull requestgem install hub # on a mac you can `brew install hub`
hub fork
git push <your name> -your-name--update-docs-String-truncate-for-pr
hub pull-request
# Celebrate!