ruby - acronym
* split -> scan much cleaner!
This commit is contained in:
parent
b2c0073bb3
commit
0a632f27dd
@ -1,9 +1,5 @@
|
|||||||
class Acronym
|
class Acronym
|
||||||
def self.abbreviate(long_name)
|
def self.abbreviate(long_name)
|
||||||
abbrev = ""
|
long_name.scan(/\b\w/).join.upcase
|
||||||
long_name.split(/[\W-]+/).each do |word|
|
|
||||||
abbrev += word[0]
|
|
||||||
end
|
|
||||||
abbrev.upcase
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user