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, letterify, method_missing, numerify, parse, rand, rand_in_range, regexify, resolve, respond_to_missing?, sample, shuffle, translate, unique, with_locale

Class Method Details

.familial(legacy_connection = NOT_GIVEN, connection: nil) ⇒ String

Produces a random family relationship.

Examples:

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

Returns:

  • (String)

Available since:

  • 1.9.2


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

def familial(legacy_connection = NOT_GIVEN, connection: nil)
  warn_for_deprecated_arguments do |keywords|
    keywords << :connection if legacy_connection != NOT_GIVEN
  end

  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:

  • (String)

Available since:

  • 1.9.2


47
48
49
# File 'lib/faker/default/relationship.rb', line 47

def in_law
  fetch('relationship.in_law')
end

.parentString

Produces a random parent relationship.

Examples:

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

Returns:

  • (String)

Available since:

  • 1.9.2


73
74
75
# File 'lib/faker/default/relationship.rb', line 73

def parent
  fetch('relationship.parent')
end

.siblingString

Produces a random sibling relationship.

Examples:

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

Returns:

  • (String)

Available since:

  • 1.9.2


86
87
88
# File 'lib/faker/default/relationship.rb', line 86

def sibling
  fetch('relationship.sibling')
end

.spouseString

Produces a random spouse relationship.

Examples:

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

Returns:

  • (String)

Available since:

  • 1.9.2


60
61
62
# File 'lib/faker/default/relationship.rb', line 60

def spouse
  fetch('relationship.spouse')
end