ruby - acronym

* split -> scan much cleaner!
This commit is contained in:
James Walker 2018-09-23 17:26:38 -05:00
parent b2c0073bb3
commit 0a632f27dd
Signed by: walkah
GPG Key ID: 3C127179D6086E93

View File

@ -1,9 +1,5 @@
class Acronym
def self.abbreviate(long_name)
abbrev = ""
long_name.split(/[\W-]+/).each do |word|
abbrev += word[0]
end
abbrev.upcase
long_name.scan(/\b\w/).join.upcase
end
end