Sha256: df4d347295266841cc5c2391754939dc352deb45a2dd799ec111352d1515ce17
Contents?: true
Size: 664 Bytes
Versions: 9
Compression:
Stored size: 664 Bytes
Contents
# frozen_string_literal: true module FFakerTW module Number extend ModuleUtils extend self def number(digits: 1) FFakerTW.numerify(generate_pattern(digits)).to_i end def decimal(whole_digits: 1, fractional_digits: 1) whole_part_pattern = generate_pattern(whole_digits) fractional_part_pattern = generate_pattern(fractional_digits).reverse FFakerTW.numerify("#{whole_part_pattern}.#{fractional_part_pattern}").to_f end private def generate_pattern(digits) raise ArgumentError.new('Digits cannot be less than 1') if digits < 1 "#{fetch_sample(1..9)}#{"#" * (digits - 1)}" end end end
Version data entries
9 entries across 9 versions & 1 rubygems