Class: Taxonifi::Model::Person
- 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
Instance Method Summary collapse
-
#compact_string ⇒ Object
Returns a string with data delimited by pipes.
-
#display_name ⇒ Object
Nothing fancy, just the data.
-
#initialize(options = {}) ⇒ Person
constructor
A new instance of Person.
-
#initials_string ⇒ Object
Return a string representing the initials, periods added.
Methods inherited from Base
#add_properties, #add_property, #ancestor_ids, #ancestors, #build, #delete_property, #replace_property
Methods included from SharedClassMethods
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( = {}) opts = { }.merge!() # Check for valid opts prior to building build(ATTRIBUTES, opts) true end |
Instance Method Details
#compact_string ⇒ Object
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_name ⇒ Object
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_string ⇒ Object
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 |