| 1 | # -*- perl -*- | ||
| 2 | # !!! DO NOT EDIT !!! | ||
| 3 | # This file was automatically generated. | ||
| 4 | package Net::Amazon::Validate::ItemSearch::us::PostalCode; | ||
| 5 | |||
| 6 | use 5.006; | ||
| 7 | use strict; | ||
| 8 | use warnings; | ||
| 9 | |||
| 10 | sub new { | ||
| 11 | my ($class , %options) = @_; | ||
| 12 | my $self = { | ||
| 13 | '_default' => 'Music', | ||
| 14 | %options, | ||
| 15 | }; | ||
| 16 | |||
| 17 | push @{$self->{_options}}, 'Classical'; | ||
| 18 | push @{$self->{_options}}, 'DVD'; | ||
| 19 | push @{$self->{_options}}, 'Music'; | ||
| 20 | push @{$self->{_options}}, 'VHS'; | ||
| 21 | push @{$self->{_options}}, 'Video'; | ||
| 22 | |||
| 23 | bless $self, $class; | ||
| 24 | } | ||
| 25 | |||
| 26 | sub user_or_default { | ||
| 27 | my ($self, $user) = @_; | ||
| 28 | if (defined $user && length($user) > 0) { | ||
| 29 | return $self->find_match($user); | ||
| 30 | } | ||
| 31 | return $self->default(); | ||
| 32 | } | ||
| 33 | |||
| 34 | sub default { | ||
| 35 | my ($self) = @_; | ||
| 36 | return $self->{_default}; | ||
| 37 | } | ||
| 38 | |||
| 39 | sub find_match { | ||
| 40 | my ($self, $value) = @_; | ||
| 41 | for (@{$self->{_options}}) { | ||
| 42 | return $_ if lc($_) eq lc($value); | ||
| 43 | } | ||
| 44 | die "$value is not a valid value for us::PostalCode!\n"; | ||
| 45 | } | ||
| 46 | |||
| 47 | 1; | ||
| 48 | |||
| 49 | __END__ |