File: array_helpers.rb

package info (click to toggle)
ruby-shoulda 4.0.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 300 kB
  • sloc: ruby: 784; sh: 45; makefile: 4
file content (13 lines) | stat: -rw-r--r-- 267 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
module AcceptanceTests
  module ArrayHelpers
    def to_sentence(array)
      if array.size == 1
        array[0]
      elsif array.size == 2
        array.join(' and ')
      else
        to_sentence(array[1..-2].join(', '), [array[-1]])
      end
    end
  end
end