Module: FFaker::Number

Extended by:
ModuleUtils, Number
Included in:
Number
Defined in:
lib/ffaker/number.rb

Instance Method Summary collapse

Methods included from ModuleUtils

const_missing, k, luhn_check, underscore, unique

Methods included from RandomUtils

#fetch_sample, #rand, #shuffle

Instance Method Details

#between(from: 1.00, to: 5000.00) ⇒ Object



18
19
20
# File 'lib/ffaker/number.rb', line 18

def between(from: 1.00, to: 5000.00)
  fetch_sample(from..to)
end

#decimal(whole_digits: 1, fractional_digits: 1) ⇒ Object



12
13
14
15
16
# File 'lib/ffaker/number.rb', line 12

def decimal(whole_digits: 1, fractional_digits: 1)
  whole_part_pattern = generate_pattern(whole_digits)
  fractional_part_pattern = generate_pattern(fractional_digits).reverse
  FFaker.numerify("#{whole_part_pattern}.#{fractional_part_pattern}").to_f
end

#number(digits: 1) ⇒ Object



8
9
10
# File 'lib/ffaker/number.rb', line 8

def number(digits: 1)
  FFaker.numerify(generate_pattern(digits)).to_i
end