class Faker::Number

def decimal(l_digits: 5, r_digits: 2)

Returns:
  • (Float) -

Parameters:
  • r_digits (Integer) -- Number of digits that the generated decimal should have to the right of the decimal point.
  • l_digits (Integer) -- Number of digits that the generated decimal should have to the left of the decimal point.
def decimal(l_digits: 5, r_digits: 2)
  l_d = number(digits: l_digits)
  # Ensure the last digit is not zero
  # so it does not get truncated on converting to float
  r_d = generate(r_digits - 1).join + non_zero_digit.to_s
  "#{l_d}.#{r_d}".to_f
end