Class: Randrizer::Types::StringSequence
- Defined in:
- lib/randrizer/types/string_sequence.rb
Constant Summary collapse
- ALLOWED_TYPES =
[ Types::Int, Types::String, Types::Const, Types::Nullable, Types::Optional, Types::OneOf ].freeze
Instance Method Summary collapse
- #empty? ⇒ Boolean
- #eval ⇒ Object
-
#initialize(sequence_def) ⇒ StringSequence
constructor
A new instance of StringSequence.
- #validate! ⇒ Object
Constructor Details
#initialize(sequence_def) ⇒ StringSequence
Returns a new instance of StringSequence.
17 18 19 |
# File 'lib/randrizer/types/string_sequence.rb', line 17 def initialize(sequence_def) @sequence_def = sequence_def end |
Instance Method Details
#empty? ⇒ Boolean
31 32 33 |
# File 'lib/randrizer/types/string_sequence.rb', line 31 def empty? @sequence_def.empty? end |
#eval ⇒ Object
27 28 29 |
# File 'lib/randrizer/types/string_sequence.rb', line 27 def eval @sequence_def.map(&:eval).reject { |evaluated| evaluated == SKIP }.compact.join end |
#validate! ⇒ Object
21 22 23 24 25 |
# File 'lib/randrizer/types/string_sequence.rb', line 21 def validate! disallowed = @sequence_def.reject { |item| ALLOWED_TYPES.include?(item.class) } raise ValidationError("types not allowed in a string sequence: #{disallowed}") end |