Class: Mongoid::Sex::Value

Inherits:
Object
  • Object
show all
Defined in:
lib/mongoid-sex/value.rb

Instance Method Summary collapse

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

Returns:

  • (Boolean)


16
17
18
# File 'lib/mongoid-sex/value.rb', line 16

def female?
  !@male
end

#hesheObject 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

#hisherObject 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

Returns:

  • (Boolean)


12
13
14
# File 'lib/mongoid-sex/value.rb', line 12

def male?
  @male
end

#textObject 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