Sha256: 0720d553397a68e70e90764c190859135169efe383d3eebbf13efa85df6649fd
Contents?: true
Size: 1.14 KB
Versions: 1
Compression:
Stored size: 1.14 KB
Contents
module Fakeit module Openapi module Example BIG_INT = 2**32 def integer_example(example_options) example_options[:static] ? static_integer_example : random_integer_example end private def static_integer_example if enum enum.to_a.first else int_rand_begin * int_multiple end end def random_integer_example if enum enum.to_a.sample else Faker::Number.between(int_rand_begin, int_rand_end) * int_multiple end end def int_rand_begin min_int / int_multiple + int_rand_begin_adjust end def int_rand_end max_int / int_multiple end def int_rand_begin_adjust (min_int % int_multiple).zero? ? 0 : 1 end def int_multiple multipleOf || 1 end def min_int if minimum exclusiveMinimum ? minimum + 1 : minimum else 1 end end def max_int if maximum exclusiveMaximum ? maximum - 1 : maximum else BIG_INT end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fakeit-0.2.0 | lib/fakeit/openapi/example/integer_example.rb |