class Faker::Number
def decimal(legacy_l_digits = NOT_GIVEN, legacy_r_digits = NOT_GIVEN, l_digits: 5, r_digits: 2)
-
(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(legacy_l_digits = NOT_GIVEN, legacy_r_digits = NOT_GIVEN, l_digits: 5, r_digits: 2) warn_for_deprecated_arguments do |keywords| keywords << :l_digits if legacy_l_digits != NOT_GIVEN keywords << :r_digits if legacy_r_digits != NOT_GIVEN end 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