aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/Geocode/Address.pm
blob: 522091f6256871803ddc0dc422247b9a6e1fb3b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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;