Class: Flags::RangeValidator

Inherits:
FlagValidator show all
Defined in:
lib/flags.rb

Overview

A validator that raises an error if the flag’s value is outside the given Range. No type checking is performed (that’s the job of the ClassValidator).

Instance Method Summary collapse

Methods inherited from FlagValidator

#validate!

Constructor Details

#initialize(range) ⇒ RangeValidator

Returns a new instance of RangeValidator.



387
388
389
390
391
# File 'lib/flags.rb', line 387

def initialize(range)
  proc = Proc.new { |flag_value| range.include?(flag_value) }
  error_message = "value out of range! Valid range is #{range.inspect}"
  super(proc, error_message)
end