No commit activity in last 3 years
No release in over 3 years
This library borned from the early versions of string_utility_belt gem, this gem adds new common purpose methods to String class. E.g: split a string in words, replace a sequence of spaces per a unique space.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

serradura/stringub-commons

Links

https://rubygems.org/gems/stringub-commons

https://github.com/serradura/stringub-commons

Description

This library borned from the early versions of string_utility_belt gem, this gem adds new common purpose methods to String class. E.g: split a string in words, replace a sequence of spaces per a unique space.

Install

gem install stringub_commons

Examples

Method: words

Split strings into an array of words.

# Ex:
"Ruby on Rails".words
# >> ["Ruby", "on", "Rails"]

"Serradura's house".words
# >> ["Serradura's", "house"]

# If you question yourself:
# Whats the difference between the standard method String#split and words method?

"a, b, c, d-e,@ f'g.**".split
# >> ["a,", "b,", "c,", "d-e,@", "f'g.**"]

"a, b, c, d-e,@ f'g.**".words
# >> ["a", "b", "c", "d-e", "f'g"]

# The answer is:
# the words method just take words!   

Method: unique_spaces

Removes a sequence of any kind of space characters per a unique whitespace. " \n abc \n\n\r\t def \n\r ghi \n".unique_spaces # >> " abc def ghi "

#Tip:
#If do you need remove trailing whitespaces. chain the String#strip method:

"       \n    abc   \n\n\r\t def \n\r  ghi \n".unique_spaces.strip
# >> "abc def ghi"

More examples can be founds in the tests.