Sha256: 3e37b69114ccf33d1028bb0807b7323d42717bca9353ccf9dcf3b6e4631faf09
Contents?: true
Size: 1017 Bytes
Versions: 10
Compression:
Stored size: 1017 Bytes
Contents
class String def indefinite_article if WORDS_WITH_INITIAL_VOWELS_THAT_ACT_LIKE_WORDS_WITH_INITIAL_CONSONANTS.include? first_word.first_term INDEFINITE_ARTICLES[:consonant] elsif VOWELS.include? first.downcase INDEFINITE_ARTICLES[:vowel] else INDEFINITE_ARTICLES[:consonant] end end def with_indefinite_article(upcase = false) "#{upcase ? indefinite_article.humanize : indefinite_article}#{ ' ' unless self.blank? }#{self}" end def pluralize_on(qty) qty.is_a?(Numeric) and qty > 1 ? pluralize : self end def first_word split(' ').first end def first_term split('-').first end WORDS_WITH_INITIAL_VOWELS_THAT_ACT_LIKE_WORDS_WITH_INITIAL_CONSONANTS = %w(one) INDEFINITE_ARTICLES = { :vowel => 'an', :consonant => 'a'} VOWELS = %w(a e i o u) end class Object def recursive_send(*methods) return self if methods.empty? m = methods.shift send(m).recursive_send(*methods) end end
Version data entries
10 entries across 10 versions & 1 rubygems