class Faker::Number

def number(digits: 10)

Returns:
  • (Integer) -

Parameters:
  • digits (Integer) -- Number of digits that the generated number should have.
def number(digits: 10)
  return if digits < 1
  return rand(0..9).round if digits == 1
  # Ensure the first digit is not zero
  ([non_zero_digit] + generate(digits - 1)).join.to_i
end