Class: MatchMate::Address

Inherits:
Object
  • Object
show all
Defined in:
lib/match-mate/address.rb

Class Method Summary collapse

Instance Method Summary collapse

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

.languagesObject



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

#cityObject



25
26
27
# File 'lib/match-mate/address.rb', line 25

def city
  components[:city]
end

#city_and_stateObject

Normalized Compositites



46
47
48
# File 'lib/match-mate/address.rb', line 46

def city_and_state
  [city, state].compact.join(', ')
end

#house_numberObject



33
34
35
# File 'lib/match-mate/address.rb', line 33

def house_number
  components[:house_number]
end

#postcodeObject



21
22
23
# File 'lib/match-mate/address.rb', line 21

def postcode
  limit_to components[:postcode], MatchMate.config.postcode_limit
end

#roadObject

Basic Components for comparsion



13
14
15
# File 'lib/match-mate/address.rb', line 13

def road
  expand components[:road]
end

#stateObject



29
30
31
# File 'lib/match-mate/address.rb', line 29

def state
  components[:state]
end

#street_addressObject



50
51
52
# File 'lib/match-mate/address.rb', line 50

def street_address
  [house_number, road.last].compact.join(' ')
end

#street_adress_with_unitObject



54
55
56
# File 'lib/match-mate/address.rb', line 54

def street_adress_with_unit
  [street_address, unit].compact.join(' ')
end

#to_sObject



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

#unitObject



17
18
19
# File 'lib/match-mate/address.rb', line 17

def unit
  extract_integers components[:unit]
end