Sha256: 1020da89a6ae12303947cbf19a95b29d9c8d677932c16fc36d7c2d72e07f5c4e

Contents?: true

Size: 583 Bytes

Versions: 2

Compression:

Stored size: 583 Bytes

Contents

## String#random

    require 'facets/string/random'

Generates a random string of given length, using given character set

    s = String.random
    # "D9DxFIaqR3dr8Ct1AfmFxHxqGsmA4Oz3"
    s.assert =~ /^[0-9a-zA-Z]{32}$/

    s = String.random(10)
    # "t8BIna341S"
    s.assert =~ /^[0-9a-zA-Z]{10}$/

    s = String.random(10, ['a'..'z'])
    # "nstpvixfri"
    s.assert =~ /^[a-z]{10}$/

    s = String.random(10, ['0'..'9'] )
    # "0982541042"
    s.assert =~ /^[0-9]{10}$/

    s = String.random(10, ['0'..'9','A'..'F'] )
    # "3EBF48AD3D"
    s.assert =~ /^[0-9A-F]{10}$/

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
facets-glimmer-3.2.0 demo/core/string/random.md
facets-3.1.0 demo/core/string/random.md