Class: Faker::FunnyName

Inherits:
Base
  • Object
show all
Defined in:
lib/faker/default/funny_name.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

.four_word_nameString

Retrieves a funny four word name.

Examples:

Faker::FunnyName.four_word_name #=> "Maude L. T. Ford"

Returns:

  • (String)

Available since:

  • 1.8.0



64
65
66
67
68
69
70
# File 'lib/faker/default/funny_name.rb', line 64

def four_word_name
  four_word_names = fetch_all('funny_name.name').select do |name|
    name.count(' ') == 3
  end

  sample(four_word_names)
end

.nameString

Retrieves a funny name.

Examples:

Faker::FunnyName.name #=> "Sam Pull"

Returns:

  • (String)

Available since:

  • 1.8.0



17
18
19
# File 'lib/faker/default/funny_name.rb', line 17

def name
  fetch('funny_name.name')
end

.name_with_initialString

Retrieves a funny name with an initial.

Examples:

Faker::FunnyName.name_with_initial #=> "Heather N. Yonn"

Returns:

  • (String)

Available since:

  • 1.8.0



81
82
83
84
85
86
87
# File 'lib/faker/default/funny_name.rb', line 81

def name_with_initial
  names_with_initials = fetch_all('funny_name.name').select do |name|
    name.count('.').positive?
  end

  sample(names_with_initials)
end

.three_word_nameString

Retrieves a funny three word name.

Examples:

Faker::FunnyName.three_word_name #=> "Carson O. Gin"

Returns:

  • (String)

Available since:

  • 1.8.0



47
48
49
50
51
52
53
# File 'lib/faker/default/funny_name.rb', line 47

def three_word_name
  three_word_names = fetch_all('funny_name.name').select do |name|
    name.count(' ') == 2
  end

  sample(three_word_names)
end

.two_word_nameString

Retrieves a funny two word name.

Examples:

Faker::FunnyName.two_word_name #=> "Shirley Knot"

Returns:

  • (String)

Available since:

  • 1.8.0



30
31
32
33
34
35
36
# File 'lib/faker/default/funny_name.rb', line 30

def two_word_name
  two_word_names = fetch_all('funny_name.name').select do |name|
    name.count(' ') == 1
  end

  sample(two_word_names)
end