Class: MatchMate::Address
- Inherits:
-
Object
- Object
- MatchMate::Address
- Defined in:
- lib/match-mate/address.rb
Class Method Summary collapse
Instance Method Summary collapse
- #==(other_address) ⇒ Object (also: #eql?, #===)
- #city ⇒ Object
-
#city_and_state ⇒ Object
Normalized Compositites.
- #house_number ⇒ Object
-
#initialize(input_object_or_string) ⇒ Address
constructor
A new instance of Address.
- #postcode ⇒ Object
-
#road ⇒ Object
Basic Components for comparsion.
- #state ⇒ Object
- #street_address ⇒ Object
- #street_adress_with_unit ⇒ Object
- #to_s ⇒ Object
- #unit ⇒ Object
Constructor Details
#initialize(input_object_or_string) ⇒ Address
Returns a new instance of Address.
7 8 9 10 |
# File 'lib/match-mate/address.rb', line 7 def initialize(input_object_or_string) # Accepts any address object that responds to a to_s method @input_string = input_object_or_string.to_s end |
Class Method Details
.languages ⇒ Object
3 4 5 |
# File 'lib/match-mate/address.rb', line 3 def self.languages @languages ||= MatchMate.config.languages || DEFAULTS[:languages] end |
Instance Method Details
#==(other_address) ⇒ Object Also known as: eql?, ===
37 38 39 |
# File 'lib/match-mate/address.rb', line 37 def ==(other_address) AddressMatcher.new(self, other_address).match? end |
#city ⇒ Object
25 26 27 |
# File 'lib/match-mate/address.rb', line 25 def city components[:city] end |
#city_and_state ⇒ Object
Normalized Compositites
46 47 48 |
# File 'lib/match-mate/address.rb', line 46 def city_and_state [city, state].compact.join(', ') end |
#house_number ⇒ Object
33 34 35 |
# File 'lib/match-mate/address.rb', line 33 def house_number components[:house_number] end |
#postcode ⇒ Object
21 22 23 |
# File 'lib/match-mate/address.rb', line 21 def postcode limit_to components[:postcode], MatchMate.config.postcode_limit end |
#road ⇒ Object
Basic Components for comparsion
13 14 15 |
# File 'lib/match-mate/address.rb', line 13 def road components[:road] end |
#state ⇒ Object
29 30 31 |
# File 'lib/match-mate/address.rb', line 29 def state components[:state] end |
#street_address ⇒ Object
50 51 52 |
# File 'lib/match-mate/address.rb', line 50 def street_address [house_number, road.last].compact.join(' ') end |
#street_adress_with_unit ⇒ Object
54 55 56 |
# File 'lib/match-mate/address.rb', line 54 def street_adress_with_unit [street_address, unit].compact.join(' ') end |
#to_s ⇒ Object
58 59 60 |
# File 'lib/match-mate/address.rb', line 58 def to_s [street_adress_with_unit, city_and_state, zip_code].compact.join(', ') end |
#unit ⇒ Object
17 18 19 |
# File 'lib/match-mate/address.rb', line 17 def unit extract_integers components[:unit] end |