diff options
Diffstat (limited to 'perllib/FixMyStreet/Geocode/Address.pm')
-rw-r--r-- | perllib/FixMyStreet/Geocode/Address.pm | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/Geocode/Address.pm b/perllib/FixMyStreet/Geocode/Address.pm new file mode 100644 index 000000000..522091f62 --- /dev/null +++ b/perllib/FixMyStreet/Geocode/Address.pm @@ -0,0 +1,28 @@ +package FixMyStreet::Geocode::Address; + +use strict; +use warnings; + +use overload '""' => \&as_string, fallback => 1; + +sub new { + my ($class, $data) = @_; + my $self = { %$data }; + bless $self, $class; +} + +sub as_string { + my $self = shift; + + my $data = sprintf(_("Nearest road to the pin placed on the map (automatically generated by Bing Maps): %s"), + $self->{name}) . "\n\n"; + + if ($self->{postcode}) { + $data .= sprintf(_("Nearest postcode to the pin placed on the map (automatically generated): %s (%sm away)"), + $self->{postcode}{postcode}, $self->{postcode}{distance}) . "\n\n"; + } + + return $data; +} + +1; |