Class: GoImport::Coworker
Instance Method Summary
collapse
#get_import_rows, #serialize, #serialize_to_file
immutable_accessor, #is_immutable, #raise_if_immutable, #set_is_immutable
Constructor Details
#initialize(opt = nil) ⇒ Coworker
Returns a new instance of Coworker.
14
15
16
17
18
19
20
21
|
# File 'lib/go_import/model/coworker.rb', line 14
def initialize(opt = nil)
if opt != nil
serialize_variables.each do |myattr|
val = opt[myattr[:id]]
instance_variable_set("@" + myattr[:id].to_s, val) if val != nil
end
end
end
|
Instance Method Details
#==(that) ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/go_import/model/coworker.rb', line 43
def ==(that)
if that.nil?
return false
end
if that.is_a? Coworker
return @integration_id == that.integration_id
end
return false
end
|
#guess_email(domain) ⇒ Object
72
73
74
75
76
77
78
79
|
# File 'lib/go_import/model/coworker.rb', line 72
def guess_email(domain)
return '' if @last_name.nil? || @last_name.empty?
return '' if @first_name.nil? || @first_name.empty?
firstname = to_email_chars @first_name.downcase
lastname = to_email_chars @last_name.downcase
return "#{firstname}.#{lastname}@#{domain}"
end
|
#parse_name_to_firstname_lastname_se(name, when_missing = '') ⇒ Object
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/go_import/model/coworker.rb', line 55
def parse_name_to_firstname_lastname_se(name, when_missing = '')
if name.nil? or name.empty?
@first_name = when_missing
return
end
splitted = name.split(' ')
@first_name = splitted[0]
if splitted.length > 1
@last_name = splitted.drop(1).join(' ')
end
end
|
#serialize_name ⇒ Object
39
40
41
|
# File 'lib/go_import/model/coworker.rb', line 39
def serialize_name
"Coworker"
end
|
#serialize_variables ⇒ Object
23
24
25
26
27
28
|
# File 'lib/go_import/model/coworker.rb', line 23
def serialize_variables
[
:id, :integration_id, :email, :first_name, :last_name,
:direct_phone_number, :mobile_phone_number, :home_phone_number
].map {|p| { :id => p, :type => :string } }
end
|
#to_email_chars(s) ⇒ Object
68
69
70
|
# File 'lib/go_import/model/coworker.rb', line 68
def to_email_chars(s)
s.tr " åäöèé", "-aaoee"
end
|
#to_reference ⇒ Object
30
31
32
33
34
35
36
37
|
# File 'lib/go_import/model/coworker.rb', line 30
def to_reference
reference = CoworkerReference.new
reference.id = @id
reference.integration_id = @integration_id
reference.heading = "#{@first_name} #{@last_name}".strip
return reference
end
|