Class: Strict::Validators::RangeOf
- Inherits:
-
Object
- Object
- Strict::Validators::RangeOf
- Defined in:
- lib/strict/validators/range_of.rb
Instance Attribute Summary collapse
-
#element_validator ⇒ Object
readonly
Returns the value of attribute element_validator.
Instance Method Summary collapse
- #===(value) ⇒ Object
-
#initialize(element_validator) ⇒ RangeOf
constructor
A new instance of RangeOf.
- #inspect ⇒ Object (also: #to_s)
Constructor Details
#initialize(element_validator) ⇒ RangeOf
Returns a new instance of RangeOf.
8 9 10 |
# File 'lib/strict/validators/range_of.rb', line 8 def initialize(element_validator) @element_validator = element_validator end |
Instance Attribute Details
#element_validator ⇒ Object (readonly)
Returns the value of attribute element_validator.
6 7 8 |
# File 'lib/strict/validators/range_of.rb', line 6 def element_validator @element_validator end |
Instance Method Details
#===(value) ⇒ Object
12 13 14 15 16 |
# File 'lib/strict/validators/range_of.rb', line 12 def ===(value) Range === value && [value.begin, value.end].compact.all? do |v| element_validator === v end end |
#inspect ⇒ Object Also known as: to_s
18 19 20 |
# File 'lib/strict/validators/range_of.rb', line 18 def inspect "RangeOf(#{element_validator.inspect})" end |