Class: Array

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

Instance Method Summary collapse

Instance Method Details

#to_phrase(last_join = "and") ⇒ Object



46
47
48
49
50
51
52
53
54
55
# File 'lib/webbynode.rb', line 46

def to_phrase(last_join="and")
  return "" if empty?

  array = self.clone
  last = array.pop

  return last if array.empty?

  "#{array.join(", ")} #{last_join} #{last}"
end