Class: Boolminot::Helpers::RangeBoundsValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/boolminot/helpers/range_bounds_validator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#boundsObject (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

Returns:

  • (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