Class: PoroValidator::Validators::RangeArrayValidator

Inherits:
BaseClass
  • Object
show all
Defined in:
lib/poro_validator/validators/range_array_validator.rb

Overview

Since:

  • 0.0.1

Direct Known Subclasses

ExclusionValidator, InclusionValidator

Instance Attribute Summary

Attributes inherited from BaseClass

#attribute

Instance Method Summary collapse

Methods inherited from BaseClass

#__validate__, #context, #errors, #initialize, #nested?, #options, #validate, #value

Constructor Details

This class inherits a constructor from PoroValidator::Validators::BaseClass

Instance Method Details

#covered?(range, value) ⇒ Boolean

Returns:

  • (Boolean)

Since:

  • 0.0.1



8
9
10
11
# File 'lib/poro_validator/validators/range_array_validator.rb', line 8

def covered?(range, value)
  return unless range.respond_to?(:cover?)
  range.cover?(value)
end

#included?(array, value) ⇒ Boolean

Returns:

  • (Boolean)

Since:

  • 0.0.1



13
14
15
16
# File 'lib/poro_validator/validators/range_array_validator.rb', line 13

def included?(array, value)
  return unless array.respond_to?(:include?)
  array.include?(value)
end

#validate_option(option) ⇒ Object

Since:

  • 0.0.1



4
5
6
# File 'lib/poro_validator/validators/range_array_validator.rb', line 4

def validate_option(option)
  !option.nil? && (option.is_a?(::Range) || option.is_a?(::Array))
end