Class: SampleModels::AttributeSequence::LengthSource

Inherits:
AbstractSource show all
Defined in:
lib/sample_models/attribute_sequence.rb

Instance Method Summary collapse

Methods inherited from AbstractSource

#next

Constructor Details

#initialize(validation) ⇒ LengthSource

Returns a new instance of LengthSource.



72
73
74
75
# File 'lib/sample_models/attribute_sequence.rb', line 72

def initialize(validation)
  super()
  @validation = validation
end

Instance Method Details

#valueObject



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/sample_models/attribute_sequence.rb', line 77

def value
  minimum = @validation.config[:minimum]
  minimum ||= (
    @validation.config[:within] && @validation.config[:within].begin
  )
  minimum ||= (
    @validation.config[:in] && @validation.config[:in].begin
  )
  minimum ||= 1
  value = 'a' * minimum
  @number.times do
    value = value.succ
  end
  value
end