Class: Randrizer::Types::OneOf

Inherits:
BaseType
  • Object
show all
Defined in:
lib/randrizer/types/one_of.rb

Instance Method Summary collapse

Constructor Details

#initialize(list_def) ⇒ OneOf

Returns a new instance of OneOf.



8
9
10
# File 'lib/randrizer/types/one_of.rb', line 8

def initialize(list_def)
  @list_def = list_def
end

Instance Method Details

#evalObject



16
17
18
# File 'lib/randrizer/types/one_of.rb', line 16

def eval
  @list_def.sample.eval
end

#lengthObject Also known as: count



20
21
22
# File 'lib/randrizer/types/one_of.rb', line 20

def length
  @list_def.length
end

#validate!Object



12
13
14
# File 'lib/randrizer/types/one_of.rb', line 12

def validate!
  !@list_def.nil?
end