Class: Faker::Relationship

Inherits:
Base
  • Object
show all
Defined in:
lib/faker/default/relationship.rb

Constant Summary

Constants inherited from Base

Base::Letters, Base::Numbers, Base::ULetters

Class Method Summary collapse

Methods inherited from Base

bothify, disable_enforce_available_locales, fetch, fetch_all, flexible, letterify, method_missing, numerify, parse, rand, rand_in_range, regexify, resolve, respond_to_missing?, sample, shuffle, translate, unique, with_locale

Class Method Details

.familial(connection = nil) ⇒ Object


8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/faker/default/relationship.rb', line 8

def familial(connection = nil)
  familial_connections = translate('faker.relationship.familial').keys

  if connection.nil?
    connection = sample(familial_connections).to_s
  else
    connection = connection.to_s.downcase

    unless familial_connections.include?(connection.to_sym)
      raise ArgumentError,
            "Familial connections can be left blank or #{familial_connections.join(', ')}"
    end
  end

  fetch('relationship.familial.' + connection)
end

.in_lawObject


25
26
27
# File 'lib/faker/default/relationship.rb', line 25

def in_law
  fetch('relationship.in_law')
end

.parentObject


33
34
35
# File 'lib/faker/default/relationship.rb', line 33

def parent
  fetch('relationship.parent')
end

.siblingObject


37
38
39
# File 'lib/faker/default/relationship.rb', line 37

def sibling
  fetch('relationship.sibling')
end

.spouseObject


29
30
31
# File 'lib/faker/default/relationship.rb', line 29

def spouse
  fetch('relationship.spouse')
end