Class: Pact::Generator::RandomInt

Inherits:
Object
  • Object
show all
Defined in:
lib/pact/generator/random_int.rb

Overview

RandomInt provides the random int generator which generate a random integer, with a min/max

Instance Method Summary collapse

Instance Method Details

#call(hash, _params = nil, _example_value = nil) ⇒ Object



9
10
11
12
13
# File 'lib/pact/generator/random_int.rb', line 9

def call(hash, _params = nil, _example_value = nil)
  min = hash['min'] || 0
  max = hash['max'] || 2_147_483_647
  rand(min..max)
end

#can_generate?(hash) ⇒ Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/pact/generator/random_int.rb', line 5

def can_generate?(hash)
  hash.key?('type') && hash['type'] == 'RandomInt'
end