Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/irc/extensions.rb

Instance Method Summary collapse

Instance Method Details

#to_sentenceObject



2
3
4
5
6
7
8
9
10
11
12
13
# File 'lib/irc/extensions.rb', line 2

def to_sentence
  case length
  when 0
    ''
  when 1
    self[0].to_s
  when 2
    "#{self[0]} and #{self[1]}"
  else
    "#{self[0..-2].join(', ')}, and #{self.last}"
  end
end