Class: Faker::Relationship

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

Constant Summary

Constants inherited from Base

Base::LLetters, Base::Letters, Base::NOT_GIVEN, Base::Numbers, Base::ULetters

Class Method Summary collapse

Methods inherited from Base

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

Class Method Details

.familial(connection: nil) ⇒ String

Produces a random family relationship.

Examples:

Faker::Relationship.familial #=> "Grandfather"

Returns:



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/faker/default/relationship.rb', line 17

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_lawString

Produces a random in-law relationship.

Examples:

Faker::Relationship.in_law #=> "Brother-in-law"

Returns:



43
44
45
# File 'lib/faker/default/relationship.rb', line 43

def in_law
  fetch('relationship.in_law')
end

.parentString

Produces a random parent relationship.

Examples:

Faker::Relationship.parent #=> "Father"

Returns:



69
70
71
# File 'lib/faker/default/relationship.rb', line 69

def parent
  fetch('relationship.parent')
end

.siblingString

Produces a random sibling relationship.

Examples:

Faker::Relationship.sibling #=> "Sister"

Returns:



82
83
84
# File 'lib/faker/default/relationship.rb', line 82

def sibling
  fetch('relationship.sibling')
end

.spouseString

Produces a random spouse relationship.

Examples:

Faker::Relationship.spouse #=> "Husband"

Returns:



56
57
58
# File 'lib/faker/default/relationship.rb', line 56

def spouse
  fetch('relationship.spouse')
end