module Abb
Copyright (C) 2012 Kenichi Kamiya
Constants
- CONSONANTS
- NOT_CONSONANTS
- NOT_VOWELS
- VERSION
- VOWELS
Public Class Methods
abbreviation(str)
click to toggle source
@param str [String, to_str] @return [String]
# File lib/abb/singleton_class.rb, line 13 def abbreviation(str) str = String.try_convert(str) raise ArgumentError unless str str = str.strip return '' if str == '' case str when /\s/ initialism(str) else "#{str.slice!(0)}#{consonant!(str)}" end end
Private Class Methods
consonant!(str)
click to toggle source
@param str [String] @return [String]
# File lib/abb/singleton_class.rb, line 41 def consonant!(str) str.delete(NOT_CONSONANTS) end
initialism(str)
click to toggle source
@param str [String] @return [String]
# File lib/abb/singleton_class.rb, line 47 def initialism(str) str.scan(/\b[A-Z]/).join end
Also aliased as: acronym
vowel!(str)
click to toggle source
@param str [String] @return [String]
# File lib/abb/singleton_class.rb, line 35 def vowel!(str) str.delete(NOT_VOWELS) end