Module: CiteProc::Extensions::AliasMethods

Defined in:
lib/citeproc/extensions.rb

Overview

based and compatible to the active support version module ToSentence

def to_sentence(options = {})
  options = {
    :words_connector => ", ",
    :two_words_connector => " and ",
    :last_word_connector => ", and "
  }.merge!(options)

  case length
  when 0
    ""
  when 1
    self[0].to_s.dup
  when 2
    "#{self[0]}#{options[:two_words_connector]}#{self[1]}"
  else
    "#{self[0...-1].join(options[:words_connector])}#{options[:last_word_connector]}#{self[-1]}"
  end
end

end