Adds a .joined method to Array
Do you know to_sentence from Rails?
This gem does exactly the same, but without Rails.
require 'joined'
puts ['orange', 'banana', 'pear'].joined
Prints:
orange, banana, and pear
That's it.
Options
The joined method supports the following parameters:
words_connector(String) (defaults to: ', ') - the sign or word used to join all but the last element in arrays with three or more elements.last_word_connector(String) (defaults to: ', and ') - the sign or word used to join the last element in arrays with three or more element.oxford(Boolean) (defaults to: true) - should we place a comma before thelast_word_connector? If false, it will remove a leading comma from thelast_word_connector, however, it does not add a comma if one is not already specified in thelast_word_connector.
See the Yard docs for full gem documentation.
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:
bundle update
bundle exec rake
If it's clean and you don't see any error messages, submit your pull request.