Module: Juscribe::Personhood
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/juscribe/personhood.rb
Instance Method Summary collapse
- #age ⇒ Object
- #androgynous? ⇒ Boolean
-
#birthdate ⇒ Object
Defaults to
Date.today
ifnil
. -
#email_address ⇒ Object
Email, when the db field is nil, still returns an empty string, I suppose for Devise’s sake.
- #female? ⇒ Boolean
-
#first_and_last_name ⇒ Object
Same as #full_name but omitting the middle_name.
-
#full_name ⇒ Object
Full name, unless empty, then shows “unnamed” variant.
- #male? ⇒ Boolean
- #middle_initial ⇒ Object
- #sex(format = nil) ⇒ Object
-
#to_param ⇒ Object
Override the following to control what gets displayed on #to_s.
Instance Method Details
#age ⇒ Object
57 58 59 60 61 62 |
# File 'lib/juscribe/personhood.rb', line 57 def age today, bday = Date.today, birthdate years = today.year - bday.year years.tap { |yrs| yrs -= 1 if (bday + years.years) > today } # is this logic even solid? end |
#androgynous? ⇒ Boolean
81 82 83 |
# File 'lib/juscribe/personhood.rb', line 81 def androgynous? read_attribute(:sex).nil? end |
#birthdate ⇒ Object
Defaults to Date.today
if nil
.
53 54 55 |
# File 'lib/juscribe/personhood.rb', line 53 def birthdate read_attribute(:birthdate) || Date.today end |
#email_address ⇒ Object
Email, when the db field is nil, still returns an empty string, I suppose for Devise’s sake.
48 49 50 |
# File 'lib/juscribe/personhood.rb', line 48 def email_address "#{first_and_last_name} <#{email}>" if email.present? end |
#female? ⇒ Boolean
77 78 79 |
# File 'lib/juscribe/personhood.rb', line 77 def female? sex == 'f' end |
#first_and_last_name ⇒ Object
Same as #full_name but omitting the middle_name.
42 43 44 |
# File 'lib/juscribe/personhood.rb', line 42 def first_and_last_name display_optional name.first_and_last end |
#full_name ⇒ Object
Full name, unless empty, then shows “unnamed” variant.
37 38 39 |
# File 'lib/juscribe/personhood.rb', line 37 def full_name display_optional name.full end |
#male? ⇒ Boolean
73 74 75 |
# File 'lib/juscribe/personhood.rb', line 73 def male? sex == 'm' end |
#middle_initial ⇒ Object
31 32 33 |
# File 'lib/juscribe/personhood.rb', line 31 def middle_initial display_optional name.middle_initial end |
#sex(format = nil) ⇒ Object
64 65 66 67 68 69 70 71 |
# File 'lib/juscribe/personhood.rb', line 64 def sex(format = nil) full_int = format == :full ? 1 : 0 if read_attribute(:sex) %w(female male)[self[:sex]][0..full_int.send(:-@)] else %w{? (unknown)}[full_int] end end |
#to_param ⇒ Object
Override the following to control what gets displayed on #to_s
27 28 29 |
# File 'lib/juscribe/personhood.rb', line 27 def to_param username end |