lib/picturehouse_uk/internal/parser/address.rb in picturehouse_uk-3.0.14 vs lib/picturehouse_uk/internal/parser/address.rb in picturehouse_uk-4.0.0

- old
+ new

@@ -14,25 +14,37 @@ # :postal_code, :country # @note Uses the address naming from http://microformats.org/wiki/adr def address { street_address: array[1], - extended_address: array.length > 5 ? array[2] : nil, + extended_address: extended_address, locality: town, - region: array[-2] == town ? nil : array[-2], - postal_code: array[-1], - country: 'United Kingdom' + region: region, + postal_code: postal_code, + country_name: 'United Kingdom'.freeze } end private - def town - @town ||= array[0].to_s.split(', ')[-1] - end - def array @array ||= Array(@html.gsub(/\<.?p.?\>/, '').split('<br>')) + end + + def extended_address + array.length > 5 ? array[2] : nil + end + + def postal_code + array[-1] + end + + def region + array[-2] == town ? nil : array[-2] + end + + def town + @town ||= array[0].to_s.split(', ')[-1] end end end end end