class Array

Public Instance Methods

and() click to toggle source
# File lib/the_oxford_comma.rb, line 4
def and
  case size
  when 0 then "" 
  when 1 then first
  when 2 then "#{first} and #{last}"
  else self[0..-2].join(", ") << ", and #{last}"
  end
end
or() click to toggle source
# File lib/the_oxford_comma.rb, line 13
def or
  case size
  when 0 then "" 
  when 1 then first
  when 2 then "#{first} or #{last}"
  else self[0..-2].join(", ") << ", or #{last}"
  end
end