1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-03-30 19:22:21 +00:00

Change school abbreviation if school has 3 names

This commit is contained in:
2021-02-19 17:09:47 +00:00
parent 0aea26967a
commit 89a695388a

View File

@@ -14,10 +14,15 @@ class School < ActiveRecord::Base
def abbreviation
name_array = self.name.split(' ')
if name_array.size > 1
return "#{name_array[0].chars.to_a.first}#{name_array[1].chars.to_a[0..1].join('').upcase}"
if name_array.size > 2
# If three words, use first letter of first word, first letter of second, and first two of third
return "#{name_array[0].chars.to_a.first}#{name_array[1].chars.to_a.first}#{name_array[2].chars.to_a[0..1].join('').upcase}"
elsif name_array.size > 1
# If two words use first letter of first word and first three of the second
return "#{name_array[0].chars.to_a.first}#{name_array[1].chars.to_a[0..2].join('').upcase}"
else
return "#{name_array[0].chars.to_a[0..2].join('').upcase}"
# If one word use first four letters
return "#{name_array[0].chars.to_a[0..3].join('').upcase}"
end
end