module FFaker::Random

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

# sig/ffaker.rbs

module FFaker::Random
  def self.rand: (?(Integer | Range) max) -> Integer
  def self.rng: () -> Random
end

def self.new_rng

Returns a new Random object instantiated with #seed.
def self.new_rng
  ::Random.new(seed)
end

def self.rand(max = nil)

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

def self.rand: (?(Integer | Range) max) -> Integer

This signature was generated using 6 samples from 1 application.

Returns a random number using an RNG with a known seed.
def self.rand(max = nil)
  return rng.rand(max) if max
  rng.rand
end

def self.reset!

Reset the RNG back to its initial state.
def self.reset!
  @rng = new_rng
end

def self.rng

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

def self.rng: () -> Random

This signature was generated using 6 samples from 1 application.

Returns the current Random object.
def self.rng
  @rng ||= new_rng
end

def self.seed

Returns the current RNG seed.
def self.seed
  @seed ||= ::Random.new_seed
end

def self.seed=(new_seed)

Sets the RNG seed and creates a new internal RNG.
def self.seed=(new_seed)
  @seed = new_seed
  reset!
  new_seed
end