Class: FruitToLime::Coworker
- Inherits:
-
Object
- Object
- FruitToLime::Coworker
- Includes:
- SerializeHelper
- Defined in:
- lib/fruit_to_lime/model/coworker.rb
Instance Attribute Summary collapse
-
#direct_phone_number ⇒ Object
Returns the value of attribute direct_phone_number.
-
#email ⇒ Object
Returns the value of attribute email.
-
#first_name ⇒ Object
Returns the value of attribute first_name.
-
#home_phone_number ⇒ Object
Returns the value of attribute home_phone_number.
-
#id ⇒ Object
Returns the value of attribute id.
-
#integration_id ⇒ Object
Returns the value of attribute integration_id.
-
#last_name ⇒ Object
Returns the value of attribute last_name.
-
#mobile_phone_number ⇒ Object
Returns the value of attribute mobile_phone_number.
Instance Method Summary collapse
- #==(that) ⇒ Object
- #guess_email(domain) ⇒ Object
-
#initialize(opt = nil) ⇒ Coworker
constructor
A new instance of Coworker.
- #parse_name_to_firstname_lastname_se(name, when_missing = '') ⇒ Object
- #serialize_name ⇒ Object
- #serialize_variables ⇒ Object
- #to_email_chars(s) ⇒ Object
- #to_reference ⇒ Object
Methods included from SerializeHelper
#get_import_rows, #serialize, #serialize_to_file
Constructor Details
#initialize(opt = nil) ⇒ Coworker
Returns a new instance of Coworker.
8 9 10 11 12 13 14 15 |
# File 'lib/fruit_to_lime/model/coworker.rb', line 8 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 Attribute Details
#direct_phone_number ⇒ Object
Returns the value of attribute direct_phone_number.
5 6 7 |
# File 'lib/fruit_to_lime/model/coworker.rb', line 5 def direct_phone_number @direct_phone_number end |
#email ⇒ Object
Returns the value of attribute email.
5 6 7 |
# File 'lib/fruit_to_lime/model/coworker.rb', line 5 def email @email end |
#first_name ⇒ Object
Returns the value of attribute first_name.
5 6 7 |
# File 'lib/fruit_to_lime/model/coworker.rb', line 5 def first_name @first_name end |
#home_phone_number ⇒ Object
Returns the value of attribute home_phone_number.
5 6 7 |
# File 'lib/fruit_to_lime/model/coworker.rb', line 5 def home_phone_number @home_phone_number end |
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/fruit_to_lime/model/coworker.rb', line 5 def id @id end |
#integration_id ⇒ Object
Returns the value of attribute integration_id.
5 6 7 |
# File 'lib/fruit_to_lime/model/coworker.rb', line 5 def integration_id @integration_id end |
#last_name ⇒ Object
Returns the value of attribute last_name.
5 6 7 |
# File 'lib/fruit_to_lime/model/coworker.rb', line 5 def last_name @last_name end |
#mobile_phone_number ⇒ Object
Returns the value of attribute mobile_phone_number.
5 6 7 |
# File 'lib/fruit_to_lime/model/coworker.rb', line 5 def mobile_phone_number @mobile_phone_number end |
Instance Method Details
#==(that) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/fruit_to_lime/model/coworker.rb', line 37 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
66 67 68 69 70 71 72 73 |
# File 'lib/fruit_to_lime/model/coworker.rb', line 66 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
49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/fruit_to_lime/model/coworker.rb', line 49 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
33 34 35 |
# File 'lib/fruit_to_lime/model/coworker.rb', line 33 def serialize_name "Coworker" end |
#serialize_variables ⇒ Object
17 18 19 20 21 22 |
# File 'lib/fruit_to_lime/model/coworker.rb', line 17 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
62 63 64 |
# File 'lib/fruit_to_lime/model/coworker.rb', line 62 def to_email_chars(s) s.tr " åäöèé", "-aaoee" end |
#to_reference ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/fruit_to_lime/model/coworker.rb', line 24 def to_reference reference = CoworkerReference.new reference.id = @id reference.integration_id = @integration_id reference.heading = "#{@first_name} #{@last_name}".strip return reference end |