Module: Nokogiri::XML::Schematron::Internal::CoreExt::Array
- Defined in:
- lib/nokogiri/xml/schematron/internal/core_ext/array.rb
Class Method Summary collapse
-
.to_sentence(array, **options) ⇒ String
Converts the array to a comma-separated sentence where the last element is joined by the connector word.
Class Method Details
.to_sentence(array, **options) ⇒ String
Converts the array to a comma-separated sentence where the last element is joined by the connector word.
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/nokogiri/xml/schematron/internal/core_ext/array.rb', line 16 def self.to_sentence(array, **) case array.length when 0 '' when 1 array[0].to_s.dup when 2 "#{array[0]}#{[:two_words_connector]}#{array[1]}" else "#{array[0...-1].join([:words_connector])}#{[:last_word_connector]}#{array[-1]}" end end |