Class: ValueSemantics::RangeOf
- Inherits:
-
Object
- Object
- ValueSemantics::RangeOf
- Defined in:
- lib/value_semantics/range_of.rb
Instance Attribute Summary collapse
-
#subvalidator ⇒ Object
readonly
Returns the value of attribute subvalidator.
Instance Method Summary collapse
- #===(obj) ⇒ Object
-
#initialize(subvalidator) ⇒ RangeOf
constructor
A new instance of RangeOf.
Constructor Details
#initialize(subvalidator) ⇒ RangeOf
5 6 7 |
# File 'lib/value_semantics/range_of.rb', line 5 def initialize(subvalidator) @subvalidator = subvalidator end |
Instance Attribute Details
#subvalidator ⇒ Object (readonly)
Returns the value of attribute subvalidator.
3 4 5 |
# File 'lib/value_semantics/range_of.rb', line 3 def subvalidator @subvalidator end |
Instance Method Details
#===(obj) ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/value_semantics/range_of.rb', line 9 def ===(obj) return false unless Range === obj # begin or end can be nil, if the range is beginless or endless [obj.begin, obj.end].compact.all? do |element| subvalidator === element end end |