Module: Ronin::Support::Text::Random::Mixin

Included in:
Mixin
Defined in:
lib/ronin/support/text/random/mixin.rb

Overview

A mixin for generating random text.

Since:

  • 1.0.0

Instance Method Summary collapse

Instance Method Details

#random_alpha(n = 1) ⇒ String

A random alphabetic string.

Examples:

random_alpha
# => "L"
random_alpha(10)
# => "trrwRUvpwo"

Parameters:

  • n (Integer, Range<Integer>) (defaults to: 1)

    The desired length of the String.

Returns:

  • (String)

    A random alphabetic string.

See Also:

Since:

  • 1.0.0



221
222
223
# File 'lib/ronin/support/text/random/mixin.rb', line 221

def random_alpha(n=1)
  Text::Random.alpha(n)
end

#random_alpha_numeric(n = 1) ⇒ String

A random alpha-numeric string.

Examples:

random_alpha_numeric
# => "2"
random_alpha_numeric
# => "3zWNgkzUY5"

Parameters:

  • n (Integer, Range<Integer>) (defaults to: 1)

    The desired length of the String.

Returns:

  • (String)

    A random alpha-numeric string.

See Also:

Since:

  • 1.0.0



244
245
246
# File 'lib/ronin/support/text/random/mixin.rb', line 244

def random_alpha_numeric(n=1)
  Text::Random.alpha_numeric(n)
end

#random_ascii(n = 1) ⇒ String

A random ASCII string.

Examples:

random_ascii
# => "f"
random_ascii(10)
# => "¹ý0\u0095É\u001Eðºã,"

Parameters:

  • n (Integer, Range<Integer>) (defaults to: 1)

    The desired length of the String.

Returns:

  • (String)

    A random ASCII string.

See Also:

Since:

  • 1.0.0



430
431
432
# File 'lib/ronin/support/text/random/mixin.rb', line 430

def random_ascii(n=1)
  Text::Random.ascii(n)
end

#random_control(n = 1) ⇒ String

A random control-character string.

Examples:

random_control
# => "\u0010"
random_control(10)
# => "\r\u0013\u0018\u0013\u007F\u0001\u000E\u001C\u0012\u000F"

Parameters:

  • n (Integer, Range<Integer>) (defaults to: 1)

    The desired length of the String.

Returns:

  • (String)

    A random control-character string.

See Also:

Since:

  • 1.0.0



384
385
386
# File 'lib/ronin/support/text/random/mixin.rb', line 384

def random_control(n=1)
  Text::Random.control(n)
end

#random_hex(n = 1) ⇒ String

A random hexadecimal string.

Examples:

random_hex
# => "d"
random_hex(10)
# => "fc8C3BB96f"

Parameters:

  • n (Integer, Range<Integer>) (defaults to: 1)

    The desired length of the String.

Returns:

  • (String)

    A random hexadecimal string.

See Also:

Since:

  • 1.0.0



148
149
150
# File 'lib/ronin/support/text/random/mixin.rb', line 148

def random_hex(n=1)
  Text::Random.hex(n)
end

#random_lowercase_alpha(n = 1) ⇒ String Also known as: random_lower_alpha

The lower-case alphabetic character set.

Examples:

random_lowercase_alpha
# => "r"
random_lowercase_alpha(10)
# => "bqbouadkvb"

Parameters:

  • n (Integer, Range<Integer>) (defaults to: 1)

    The desired length of the String.

Returns:

  • (String)

    The lower-case alphabetic character set.

See Also:

Since:

  • 1.0.0



196
197
198
# File 'lib/ronin/support/text/random/mixin.rb', line 196

def random_lowercase_alpha(n=1)
  Text::Random.lowercase_alpha(n)
end

#random_lowercase_hex(n = 1) ⇒ String Also known as: random_lower_hex

The lower-case hexadecimal character set.

Examples:

random_lowercase_hex
# => "e"
random_lowercase_hex(10)
# => "cfac752fcf"

Parameters:

  • n (Integer, Range<Integer>) (defaults to: 1)

    The desired length of the String.

Returns:

  • (String)

    The lower-case hexadecimal character set.

See Also:

Since:

  • 1.0.0



123
124
125
# File 'lib/ronin/support/text/random/mixin.rb', line 123

def random_lowercase_hex(n=1)
  Text::Random.lowercase_hex(n)
end

#random_numeric(n = 1) ⇒ String Also known as: random_digits

Generates a random String of numeric characters.

Examples:

random_numeric
# => "7"
random_numeric(10)
# => "9972255528"

Parameters:

  • n (Integer, Range<Integer>) (defaults to: 1)

    The desired length of the String.

Returns:

  • (String)

    A random decimal-digit string.

See Also:

Since:

  • 1.0.0



50
51
52
# File 'lib/ronin/support/text/random/mixin.rb', line 50

def random_numeric(n=1)
  Text::Random.numeric(n)
end

#random_octal(n = 1) ⇒ String

A random octal-digit string.

Examples:

random_octal
# => "7"
random_octal(10)
# => "3126172075"

Parameters:

  • n (Integer, Range<Integer>) (defaults to: 1)

    The desired length of the String.

Returns:

  • (String)

    A random octal-digit string.

See Also:

Since:

  • 1.0.0



75
76
77
# File 'lib/ronin/support/text/random/mixin.rb', line 75

def random_octal(n=1)
  Text::Random.octal(n)
end

#random_printable(n = 1) ⇒ String

The set of printable characters, including spaces.

Examples:

random_printable
# => "B"
random_printable(10)
# => "bCz&%ZV30v"

Parameters:

  • n (Integer, Range<Integer>) (defaults to: 1)

    The desired length of the String.

Returns:

  • (String)

    A random printable string.

See Also:

Since:

  • 1.0.0



361
362
363
# File 'lib/ronin/support/text/random/mixin.rb', line 361

def random_printable(n=1)
  Text::Random.printable(n)
end

#random_punctuation(n = 1) ⇒ String

A random punctuation string.

Examples:

random_punctuation
# => ")"
random_punctuation(10)
# => ":;[,;'`\"?)"

Parameters:

  • n (Integer, Range<Integer>) (defaults to: 1)

    The desired length of the String.

Returns:

  • (String)

    A random punctuation string.

See Also:

Since:

  • 1.0.0



267
268
269
# File 'lib/ronin/support/text/random/mixin.rb', line 267

def random_punctuation(n=1)
  Text::Random.punctuation(n)
end

#random_signed_ascii(n = 1) ⇒ String

The signed ASCII character set.

Examples:

random_signed_ascii
# => "d"
random_signed_ascii(10)
# => "\u00006'\u00030%i\u001Dih"

Parameters:

  • n (Integer, Range<Integer>) (defaults to: 1)

    The desired length of the String.

Returns:

  • (String)

    The signed ASCII character set.

See Also:

Since:

  • 1.0.0



407
408
409
# File 'lib/ronin/support/text/random/mixin.rb', line 407

def random_signed_ascii(n=1)
  Text::Random.signed_ascii(n)
end

#random_symbols(n = 1) ⇒ String

A random symbolic string.

Examples:

random_symbols
# => "["
random_symbols
# => ".\\=_.`>;*)"

Parameters:

  • n (Integer, Range<Integer>) (defaults to: 1)

    The desired length of the String.

Returns:

  • (String)

    A random symbolic string.

See Also:

Since:

  • 1.0.0



290
291
292
# File 'lib/ronin/support/text/random/mixin.rb', line 290

def random_symbols(n=1)
  Text::Random.symbols(n)
end

#random_uppercase_alpha(n = 1) ⇒ String Also known as: random_upper_alpha

The upper-case alphabetic character set.

Examples:

random_uppercase_alpha
# => "R"
random_uppercase_alpha(10)
# => "VMRVCQUMCM"

Parameters:

  • n (Integer, Range<Integer>) (defaults to: 1)

    The desired length of the String.

Returns:

  • (String)

    The upper-case alphabetic character set.

See Also:

Since:

  • 1.0.0



171
172
173
# File 'lib/ronin/support/text/random/mixin.rb', line 171

def random_uppercase_alpha(n=1)
  Text::Random.uppercase_alpha(n)
end

#random_uppercase_hex(n = 1) ⇒ String Also known as: random_upper_hex

The upper-case hexadecimal character set.

Examples:

random_uppercase_hex
# => "E"
random_uppercase_hex(10)
# => "2477973C18"

Parameters:

  • n (Integer, Range<Integer>) (defaults to: 1)

    The desired length of the String.

Returns:

  • (String)

    The upper-case hexadecimal character set.

See Also:

Since:

  • 1.0.0



98
99
100
# File 'lib/ronin/support/text/random/mixin.rb', line 98

def random_uppercase_hex(n=1)
  Text::Random.uppercase_hex(n)
end

#random_visible(n = 1) ⇒ String

The set of printable characters, not including spaces.

Examples:

random_visible
# => "L"
random_visible
# => "Z)zG+[$vN_"

Parameters:

  • n (Integer, Range<Integer>) (defaults to: 1)

    The desired length of the String.

Returns:

  • (String)

    A random visible string.

See Also:

Since:

  • 1.0.0



338
339
340
# File 'lib/ronin/support/text/random/mixin.rb', line 338

def random_visible(n=1)
  Text::Random.visible(n)
end

#random_whitespace(n = 1) ⇒ String Also known as: random_space

A random whitespace string.

Examples:

random_whitespace
# => "\n"
random_whitespace(10)
# => "\v\v\t \r\f\n\f\v\f"

Parameters:

  • n (Integer, Range<Integer>) (defaults to: 1)

    The desired length of the String.

Returns:

  • (String)

    A random whitespace string.

See Also:

Since:

  • 1.0.0



313
314
315
# File 'lib/ronin/support/text/random/mixin.rb', line 313

def random_whitespace(n=1)
  Text::Random.whitespace(n)
end