Class: PostcodeValidation::Domain::PotentialAddressMatch

Inherits:
Object
  • Object
show all
Defined in:
lib/postcode_validation/domain/potential_address_match.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text:, description:) ⇒ PotentialAddressMatch

Returns a new instance of PotentialAddressMatch.



4
5
6
7
# File 'lib/postcode_validation/domain/potential_address_match.rb', line 4

def initialize(text:, description:)
  @text = text
  @description = description
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



15
16
17
# File 'lib/postcode_validation/domain/potential_address_match.rb', line 15

def description
  @description
end

#textObject (readonly)

Returns the value of attribute text.



15
16
17
# File 'lib/postcode_validation/domain/potential_address_match.rb', line 15

def text
  @text
end

Instance Method Details

#postcode_matches?(postcode) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
12
13
# File 'lib/postcode_validation/domain/potential_address_match.rb', line 9

def postcode_matches?(postcode)
  normalised_postcode = letters_and_numbers_only(postcode.upcase)

  text_includes?(normalised_postcode) || description_includes?(normalised_postcode)
end