ruby - acronym
* split -> scan much cleaner!
This commit is contained in:
parent
b2c0073bb3
commit
0a632f27dd
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user