Sha256: 5edefbd51fb4130e44606f65514cf4771757076cb0d8605e5334ee3d6bb3d5ec
Contents?: true
Size: 553 Bytes
Versions: 2
Compression:
Stored size: 553 Bytes
Contents
module Cape # Provides utility methods for String objects. module Strings extend self # Returns the English plural form of _noun_, unless _count_ is +1+. The # _count_ argument is optional, and defaults to +2+. def pluralize(noun, count=2) return noun if count == 1 "#{noun}s" end # Builds an English list phrase from the elements of _array_. def to_list_phrase(array) return array.join(' and ') if (array.length <= 2) [array[0...-1].join(', '), array[-1]].join ', and ' end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
cape-1.0.1 | lib/cape/strings.rb |
cape-1.0.0 | lib/cape/strings.rb |