Sha256: 097064c38979236d3efca23d09b88557db87c87f474050723a2d3f39ca44788a

Contents?: true

Size: 538 Bytes

Versions: 1

Compression:

Stored size: 538 Bytes

Contents

module Fakeit
  module Openapi
    module Example
      BIG_INT = 2**32

      def integer_example
        if enum
          enum.to_a.sample
        else
          Faker::Number.between(min_int, max_int)
        end
      end

      private

      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.1.2 lib/fakeit/openapi/example/integer_example.rb