https://github.com/serradura/stringub-commons
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.
https://github.com/serradura/stringub-commons
Last synced: 2 days ago
JSON representation
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.
- Host: GitHub
- URL: https://github.com/serradura/stringub-commons
- Owner: serradura
- Created: 2011-07-23T01:01:57.000Z (about 14 years ago)
- Default Branch: master
- Last Pushed: 2011-07-28T03:12:32.000Z (about 14 years ago)
- Last Synced: 2025-09-10T20:10:58.602Z (29 days ago)
- Language: Ruby
- Homepage:
- Size: 105 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.markdown
Awesome Lists containing this 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.