lib/fakeit/openapi/example/number_example.rb in fakeit-0.2.0 vs lib/fakeit/openapi/example/number_example.rb in fakeit-0.2.1
- old
+ new
@@ -1,18 +1,19 @@
module Fakeit
module Openapi
module Example
- BIG_NUM = 2**32
+ MIN_NUM = -2**31
+ MAX_NUM = 2**31 - 1
def number_example(example_options)
example_options[:static] ? static_number_example : random_number_example
end
private
def static_number_example
- (num_rand_begin * num_multiple)
+ (num_rand_end * num_multiple)
.then { |result| multipleOf ? result : result.round(2) }
end
def random_number_example
(Faker::Number.between(num_rand_begin, num_rand_end) * num_multiple)
@@ -30,14 +31,14 @@
def num_multiple
multipleOf || 1
end
def min_num
- (minimum || 0).to_f.ceil(2)
+ (minimum || MIN_NUM).to_f.ceil(2)
end
def max_num
- (maximum || BIG_NUM).to_f.floor(2)
+ (maximum || MAX_NUM).to_f.floor(2)
end
end
end
end