Module: Namae::NameFormatting
- Included in:
- Name
- Defined in:
- lib/namae/name.rb
Overview
NameFormatting can be mixed in by an object providing individual name parts (family, given, suffix, particle, etc.) to add support for name formatting.
Instance Method Summary collapse
-
#display_order ⇒ String
The name in display order.
-
#initials(options = {}) ⇒ String
The name’s initials.
-
#sort_order(delimiter = ', ') ⇒ String
The name in sort order.
Instance Method Details
#display_order ⇒ String
Returns the name in display order.
14 15 16 |
# File 'lib/namae/name.rb', line 14 def display_order [given_part, family_part, suffix].compact.reject(&:empty?).join(' ') end |
#initials(options = {}) ⇒ String
Returns the name’s initials.
25 26 27 28 29 30 31 32 33 |
# File 'lib/namae/name.rb', line 25 def initials( = {}) = Name.defaults[:initials].merge() if [:expand] [initials_of(given_part, ), family].compact.join(' ') else initials_of([given_part, family_part].join(' '), ) end end |
#sort_order(delimiter = ', ') ⇒ String
Returns the name in sort order.
9 10 11 |
# File 'lib/namae/name.rb', line 9 def sort_order(delimiter = ', ') [family_part, suffix, given_part].compact.reject(&:empty?).join(delimiter) end |