Project

ellipsized

0.0
No release in over 3 years
It makes a string fit into a required length by replacing part of it in the middle with an ellipsis.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies
 Project Readme

Adds a .ellipsized method to String

DevOps By Rultor.com We recommend RubyMine

rake PDD status Gem Version Test Coverage Yard Docs Hits-of-Code License

It makes a string fit into a required length by replacing part of it in the middle with an ellipsis:

require 'ellipsized'
puts 'Hello, dear world!'.ellipsized(16)

Prints:

Hello, ...world!

You can also specify what to use to fill the gap:

puts 'How are you doing?'.ellipsized(14, '.. skip ..')

Prints:

Ho.. skip ..g?

You can also specify alignment:

puts 'How are you doing?'.ellipsized(14, '.. skip ..', :left)

Prints:

.. skip ..ing?

That's it.

How to contribute

Read these guidelines. Make sure your build is green before you contribute your pull request. You will need to have Ruby 3.0+ and Bundler installed. Then run:

bundle update
bundle exec rake

If it's clean and you don't see any error messages, submit your pull request.