class Faker::Lorem

Experimental RBS support (using type sampling data from the type_fusion project).

# sig/faker/default/lorem.rbs

class Faker::Lorem < Faker::Base
  def locale_period: () -> String
  def locale_space: () -> String
  def sentence: (?Object legacy_word_count, ?Object legacy_supplemental, ?Object legacy_random_words_to_add, word_count: Integer, supplemental: false, random_words_to_add: Integer) -> String
  def words: (?Object legacy_number, ?Object legacy_supplemental, number: Integer, supplemental: false) -> untyped
end

Based on Perl’s Text::Lorem

def character

Returns:
  • (String) -
def character
  sample(Types::CHARACTERS)
end

def characters(legacy_number = NOT_GIVEN, number: 255, min_alpha: 0, min_numeric: 0)

Returns:
  • (String) -

Parameters:
  • min_numeric (Integer) -- The minimum number of numbers to add to the string
  • min_alpha (Integer) -- The minimum number of alphabetic to add to the string
  • number (Integer) -- The number of characters to generate
def characters(legacy_number = NOT_GIVEN, number: 255, min_alpha: 0, min_numeric: 0)
  warn_for_deprecated_arguments do |keywords|
    keywords << :number if legacy_number != NOT_GIVEN
  end
  Alphanumeric.alphanumeric(number: number, min_alpha: min_alpha, min_numeric: min_numeric)
end

def locale_period

Experimental RBS support (using type sampling data from the type_fusion project).

def locale_period: () -> String

This signature was generated using 17 samples from 1 application.

def locale_period
  translate('faker.lorem.punctuation.period') || '.'
end

def locale_question_mark

def locale_question_mark
  translate('faker.lorem.punctuation.question_mark') || '?'
end

def locale_space

Experimental RBS support (using type sampling data from the type_fusion project).

def locale_space: () -> String

This signature was generated using 11 samples from 1 application.

def locale_space
  translate('faker.lorem.punctuation.space') || ' '
end

def multibyte

Returns:
  • (String) -
def multibyte
  sample(translate('faker.lorem.multibyte')).pack('C*').force_encoding('utf-8')
end

def paragraph(legacy_sentence_count = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, legacy_random_sentences_to_add = NOT_GIVEN, sentence_count: 3, supplemental: false, random_sentences_to_add: 0)

Returns:
  • (String) -

Parameters:
  • random_sentences_to_add (Integer) --
  • supplemental (Boolean) --
  • sentence_count (Integer) -- Number of sentences in the paragraph
def paragraph(legacy_sentence_count = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, legacy_random_sentences_to_add = NOT_GIVEN, sentence_count: 3, supplemental: false, random_sentences_to_add: 0)
  warn_for_deprecated_arguments do |keywords|
    keywords << :sentence_count if legacy_sentence_count != NOT_GIVEN
    keywords << :supplemental if legacy_supplemental != NOT_GIVEN
    keywords << :random_sentences_to_add if legacy_random_sentences_to_add != NOT_GIVEN
  end
  sentences(number: resolve(sentence_count) + rand(random_sentences_to_add.to_i), supplemental: supplemental).join(locale_space)
end

def paragraph_by_chars(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 256, supplemental: false)

Returns:
  • (String) -

Parameters:
  • supplemental (Boolean) --
  • number (Integer) --
def paragraph_by_chars(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 256, supplemental: false)
  warn_for_deprecated_arguments do |keywords|
    keywords << :number if legacy_number != NOT_GIVEN
    keywords << :supplemental if legacy_supplemental != NOT_GIVEN
  end
  paragraph = paragraph(sentence_count: 3, supplemental: supplemental)
  paragraph += " #{paragraph(sentence_count: 3, supplemental: supplemental)}" while paragraph.length < number
  "#{paragraph[0...number - 1]}."
end

def paragraphs(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 3, supplemental: false)

Returns:
  • (Array) -

Parameters:
  • supplemental (Boolean) --
  • number (Integer) --
def paragraphs(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 3, supplemental: false)
  warn_for_deprecated_arguments do |keywords|
    keywords << :number if legacy_number != NOT_GIVEN
  end
  warn_for_deprecated_arguments do |keywords|
    keywords << :supplemental if legacy_supplemental != NOT_GIVEN
  end
  1.upto(resolve(number)).collect { paragraph(sentence_count: 3, supplemental: supplemental) }
end

def question(legacy_word_count = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, legacy_random_words_to_add = NOT_GIVEN, word_count: 4, supplemental: false, random_words_to_add: 0)

Returns:
  • (String) -

Parameters:
  • random_words_to_add (Integer) --
  • supplemental (Boolean) --
  • word_count (Integer) --
def question(legacy_word_count = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, legacy_random_words_to_add = NOT_GIVEN, word_count: 4, supplemental: false, random_words_to_add: 0)
  warn_for_deprecated_arguments do |keywords|
    keywords << :word_count if legacy_word_count != NOT_GIVEN
    keywords << :supplemental if legacy_supplemental != NOT_GIVEN
    keywords << :random_words_to_add if legacy_random_words_to_add != NOT_GIVEN
  end
  words(number: word_count + rand(random_words_to_add), supplemental: supplemental).join(' ').capitalize + locale_question_mark
end

def questions(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 3, supplemental: false)

Returns:
  • (Array) -

Parameters:
  • supplemental (Boolean) --
  • number (Integer) --
def questions(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 3, supplemental: false)
  warn_for_deprecated_arguments do |keywords|
    keywords << :number if legacy_number != NOT_GIVEN
    keywords << :supplemental if legacy_supplemental != NOT_GIVEN
  end
  1.upto(resolve(number)).collect { question(word_count: 3, supplemental: supplemental) }
end

def sentence(legacy_word_count = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, legacy_random_words_to_add = NOT_GIVEN, word_count: 4, supplemental: false, random_words_to_add: 0)

Experimental RBS support (using type sampling data from the type_fusion project).

def sentence: (?Object legacy_word_count, ?Object legacy_supplemental, ?Object legacy_random_words_to_add, word_count: Integer, supplemental: false, random_words_to_add: Integer) -> String

This signature was generated using 12 samples from 1 application.

Returns:
  • (String) -

Parameters:
  • random_words_to_add (Integer) -- Add any random words, default to 0
  • supplemental (Boolean) -- Add supplemental words, default to false
  • word_count (Integer) -- How many words should be there in a sentence, default to 4
def sentence(legacy_word_count = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, legacy_random_words_to_add = NOT_GIVEN, word_count: 4, supplemental: false, random_words_to_add: 0)
  warn_for_deprecated_arguments do |keywords|
    keywords << :word_count if legacy_word_count != NOT_GIVEN
    keywords << :supplemental if legacy_supplemental != NOT_GIVEN
    keywords << :random_words_to_add if legacy_random_words_to_add != NOT_GIVEN
  end
  words(number: word_count + rand(random_words_to_add.to_i), supplemental: supplemental).join(locale_space).capitalize + locale_period
end

def sentences(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 3, supplemental: false)

Returns:
  • (Array) - Returns array for sentences.

Parameters:
  • supplemental (Boolean) -- Should add supplemental words, defaults to false
  • number (Integer) -- How many sentences to be generated, default to 3
def sentences(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 3, supplemental: false)
  warn_for_deprecated_arguments do |keywords|
    keywords << :number if legacy_number != NOT_GIVEN
    keywords << :supplemental if legacy_supplemental != NOT_GIVEN
  end
  1.upto(resolve(number)).collect { sentence(word_count: 3, supplemental: supplemental) }
end

def word

Returns:
  • (String) -
def word
  sample(translate('faker.lorem.words'))
end

def words(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 3, supplemental: false)

Experimental RBS support (using type sampling data from the type_fusion project).

def words: (?Object legacy_number, ?Object legacy_supplemental, number: Integer, supplemental: false) -> untyped

This signature was generated using 9 samples from 1 application.

Returns:
  • (Array) - Array for words

Parameters:
  • supplemental (Boolean) -- Whether to attach supplemental words at the end, default is false
  • number (Integer) -- Number of words to be generated
def words(legacy_number = NOT_GIVEN, legacy_supplemental = NOT_GIVEN, number: 3, supplemental: false)
  warn_for_deprecated_arguments do |keywords|
    keywords << :number if legacy_number != NOT_GIVEN
    keywords << :supplemental if legacy_supplemental != NOT_GIVEN
  end
  resolved_num = resolve(number)
  word_list = (
    translate('faker.lorem.words') +
    (supplemental ? translate('faker.lorem.supplemental') : [])
  )
  word_list *= ((resolved_num / word_list.length) + 1)
  shuffle(word_list)[0, resolved_num]
end