Class: Taxonifi::Model::Person

Inherits:
Base
  • Object
show all
Defined in:
lib/taxonifi/model/person.rb

Overview

Simple Person class. You can store multiple initials and suffixes.

Constant Summary collapse

ATTRIBUTES =
[
  :first_name,
  :last_name,
  :initials,    # an Array, no periods.
  :suffix       # an Array
]

Instance Attribute Summary

Attributes inherited from Base

#id, #properties, #row_number

Instance Method Summary collapse

Methods inherited from Base

#add_properties, #add_property, #ancestor_ids, #ancestors, #build, #delete_property, #replace_property

Methods included from SharedClassMethods

included

Constructor Details

#initialize(options = {}) ⇒ Person

Returns a new instance of Person.



20
21
22
23
24
25
26
# File 'lib/taxonifi/model/person.rb', line 20

def initialize(options = {})
  opts = {
  }.merge!(options)
  # Check for valid opts prior to building
  build(ATTRIBUTES, opts)
  true
end

Instance Method Details

#compact_stringObject

Returns a string with data delimited by pipes. Used in identity comparisons.



30
31
32
# File 'lib/taxonifi/model/person.rb', line 30

def compact_string
  s = [ATTRIBUTES.sort.collect{|a| send(a)}].join("|").downcase.gsub(/\s/, '')
end

#display_nameObject

Nothing fancy, just the data.



35
36
37
# File 'lib/taxonifi/model/person.rb', line 35

def display_name
  [@last_name, @first_name, @initials, @suffix].compact.flatten.join(" ")
end

#initials_stringObject

Return a string representing the initials, periods added.



40
41
42
43
44
45
46
# File 'lib/taxonifi/model/person.rb', line 40

def initials_string
  if @initials.nil? 
    nil
  else 
    @initials.join(".") + "." 
  end 
end