Class: Mongoid::Sex::Value
- Inherits:
-
Object
- Object
- Mongoid::Sex::Value
- Defined in:
- lib/mongoid-sex/value.rb
Instance Method Summary collapse
- #female? ⇒ Boolean
- #heshe ⇒ Object (also: #he_she)
- #hisher ⇒ Object (also: #his_her)
-
#initialize(value) ⇒ Value
constructor
A new instance of Value.
- #male? ⇒ Boolean
- #text ⇒ Object (also: #to_s)
Constructor Details
#initialize(value) ⇒ Value
Returns a new instance of Value.
8 9 10 |
# File 'lib/mongoid-sex/value.rb', line 8 def initialize(value) @male = value end |
Instance Method Details
#female? ⇒ Boolean
16 17 18 |
# File 'lib/mongoid-sex/value.rb', line 16 def female? !@male end |
#heshe ⇒ Object Also known as: he_she
38 39 40 41 42 43 44 |
# File 'lib/mongoid-sex/value.rb', line 38 def heshe if male? I18n.t 'sex.he', default: 'he' else I18n.t 'sex.she', default: 'she' end end |
#hisher ⇒ Object Also known as: his_her
29 30 31 32 33 34 35 |
# File 'lib/mongoid-sex/value.rb', line 29 def hisher if male? I18n.t 'sex.his', default: 'his' else I18n.t 'sex.her', default: 'her' end end |
#male? ⇒ Boolean
12 13 14 |
# File 'lib/mongoid-sex/value.rb', line 12 def male? @male end |
#text ⇒ Object Also known as: to_s
20 21 22 23 24 25 26 |
# File 'lib/mongoid-sex/value.rb', line 20 def text if male? I18n.t 'sex.male', default: 'male' else I18n.t 'sex.female', default: 'female' end end |