Class: EmailAddressOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/email_address_options.rb

Constant Summary collapse

EMPLOYEEISH_AFFILIATIONS =
['employee', 'trustee', 'faculty', 'other', 'faculty emeritus']
STUDENTISH_AFFILIATIONS =
['student']
SEPARATOR =
'.'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(affiliations, preferred_name, first_name, middle_name, last_name) ⇒ EmailAddressOptions


8
9
10
11
12
13
14
# File 'lib/email_address_options.rb', line 8

def initialize(affiliations, preferred_name, first_name, middle_name, last_name)
  @affiliations = affiliations
  @preferred_name = preferred_name.to_s.strip.empty? ? first_name : preferred_name
  @first_name = first_name
  @middle_name = middle_name
  @last_name = last_name
end

Instance Attribute Details

#affiliationsObject (readonly)

Returns the value of attribute affiliations


6
7
8
# File 'lib/email_address_options.rb', line 6

def affiliations
  @affiliations
end

#first_nameObject (readonly)

Returns the value of attribute first_name


6
7
8
# File 'lib/email_address_options.rb', line 6

def first_name
  @first_name
end

#last_nameObject (readonly)

Returns the value of attribute last_name


6
7
8
# File 'lib/email_address_options.rb', line 6

def last_name
  @last_name
end

#middle_nameObject (readonly)

Returns the value of attribute middle_name


6
7
8
# File 'lib/email_address_options.rb', line 6

def middle_name
  @middle_name
end

#preferred_nameObject (readonly)

Returns the value of attribute preferred_name


6
7
8
# File 'lib/email_address_options.rb', line 6

def preferred_name
  @preferred_name
end

Instance Method Details

#to_aObject

alumnus, accepted student, non-banner alumnus don't get emails created


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/email_address_options.rb', line 17

def to_a
  options = []

  if employeeish?
    options << build_address(preferred_name, last_name)
    options << build_address(first_name, last_name)
    options << build_address(preferred_name, middle_initial, last_name)
    options << build_address(first_name, middle_initial, last_name)
    options << build_address(preferred_name, middle_name, last_name)
    options << build_address(first_name, middle_name, last_name)
  elsif studentish?
    options << build_address(preferred_name, middle_initial, last_name)
    options << build_address(first_name, middle_initial, last_name)
    options << build_address(preferred_name, middle_name, last_name)
    options << build_address(first_name, middle_name, last_name)    # NOTE: build_address will reject any blank parts.
    #       So if they have no middlename they'll get a first.last address anyway.

  end

  options.uniq
end