Class: Pact::Generator::RandomHexadecimal
- Inherits:
-
Object
- Object
- Pact::Generator::RandomHexadecimal
- Defined in:
- lib/pact/generator/random_hexadecimal.rb
Overview
RandomHexadecimal provides the random hexadecimal generator which will generate a hexadecimal
Instance Method Summary collapse
Instance Method Details
#call(hash, _params = nil, _example_value = nil) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/pact/generator/random_hexadecimal.rb', line 11 def call(hash, _params = nil, _example_value = nil) digits = hash['digits'] || 8 bytes = (digits / 2).ceil string = SecureRandom.hex(bytes) string[0, digits] end |
#can_generate?(hash) ⇒ Boolean
7 8 9 |
# File 'lib/pact/generator/random_hexadecimal.rb', line 7 def can_generate?(hash) hash.key?('type') && hash['type'] == 'RandomHexadecimal' end |