Class: AtlasEngine::AddressValidation::Validators::FullAddress::NumberComparison
- Inherits:
-
Object
- Object
- AtlasEngine::AddressValidation::Validators::FullAddress::NumberComparison
- Includes:
- Comparable
- Defined in:
- app/models/atlas_engine/address_validation/validators/full_address/number_comparison.rb
Instance Attribute Summary collapse
-
#candidate_ranges ⇒ Object
readonly
Returns the value of attribute candidate_ranges.
-
#numbers ⇒ Object
readonly
Returns the value of attribute numbers.
Instance Method Summary collapse
-
#initialize(numbers: [], candidate_ranges: []) ⇒ NumberComparison
constructor
A new instance of NumberComparison.
- #match? ⇒ Boolean
Constructor Details
#initialize(numbers: [], candidate_ranges: []) ⇒ NumberComparison
Returns a new instance of NumberComparison.
13 14 15 16 |
# File 'app/models/atlas_engine/address_validation/validators/full_address/number_comparison.rb', line 13 def initialize(numbers: [], candidate_ranges: []) @numbers = numbers @candidate_ranges = candidate_ranges end |
Instance Attribute Details
#candidate_ranges ⇒ Object (readonly)
Returns the value of attribute candidate_ranges.
11 12 13 |
# File 'app/models/atlas_engine/address_validation/validators/full_address/number_comparison.rb', line 11 def candidate_ranges @candidate_ranges end |
#numbers ⇒ Object (readonly)
Returns the value of attribute numbers.
11 12 13 |
# File 'app/models/atlas_engine/address_validation/validators/full_address/number_comparison.rb', line 11 def numbers @numbers end |
Instance Method Details
#match? ⇒ Boolean
18 19 20 21 22 23 24 25 26 |
# File 'app/models/atlas_engine/address_validation/validators/full_address/number_comparison.rb', line 18 def match? return true if candidate_ranges.blank? && numbers.present? numbers.compact.any? do |number| candidate_ranges.any? do |candidate_range| candidate_range.include?(number) end end end |