Class: Boolminot::Helpers::RangeBoundsValidator
- Inherits:
-
Object
- Object
- Boolminot::Helpers::RangeBoundsValidator
- Defined in:
- lib/boolminot/helpers/range_bounds_validator.rb
Instance Attribute Summary collapse
-
#bounds ⇒ Object
readonly
Returns the value of attribute bounds.
Instance Method Summary collapse
-
#initialize(bounds) ⇒ RangeBoundsValidator
constructor
A new instance of RangeBoundsValidator.
- #valid? ⇒ Boolean
Constructor Details
#initialize(bounds) ⇒ RangeBoundsValidator
Returns a new instance of RangeBoundsValidator.
6 7 8 |
# File 'lib/boolminot/helpers/range_bounds_validator.rb', line 6 def initialize(bounds) @bounds = bounds end |
Instance Attribute Details
#bounds ⇒ Object (readonly)
Returns the value of attribute bounds.
4 5 6 |
# File 'lib/boolminot/helpers/range_bounds_validator.rb', line 4 def bounds @bounds end |
Instance Method Details
#valid? ⇒ Boolean
10 11 12 13 14 15 16 |
# File 'lib/boolminot/helpers/range_bounds_validator.rb', line 10 def valid? good_keys = bounds.keys.all? { |key| valid_keys.include?(key) } any_bound = !(lower_bounds + upper_bounds).empty? well_defined = [lower_bounds, upper_bounds].all? { |bounds| bounds.size <= 1 } good_keys && any_bound && well_defined end |