Entry.pm 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. # ------------------------------------------------------------------------------
  2. # (C) Crown copyright Met Office. All rights reserved.
  3. # For further details please refer to the file COPYRIGHT.txt
  4. # which you should have received as part of this distribution.
  5. # ------------------------------------------------------------------------------
  6. use strict;
  7. use warnings;
  8. package Fcm::Keyword::Entry;
  9. sub new {
  10. my ($class, $args_ref) = @_;
  11. if (!$args_ref) {
  12. $args_ref = {};
  13. }
  14. return bless({%{$args_ref}}, $class);
  15. }
  16. ################################################################################
  17. ### Methods: get_*
  18. for my $name (
  19. # Returns the key of this entry
  20. 'key',
  21. # Returns the value of this entry
  22. 'value',
  23. ) {
  24. no strict qw{refs};
  25. my $getter = "get_$name";
  26. *$getter = sub {
  27. my ($self) = @_;
  28. return $self->{$name};
  29. }
  30. }
  31. 1;
  32. __END__
  33. =head1 NAME
  34. Fcm::Keyword::Entry
  35. =head1 SYNOPSIS
  36. use Fcm::Keyword::Entry;
  37. $entry = Fcm::Keyword::Entry->new({key => $key, value => $value});
  38. $key = $entry->get_key();
  39. $value = $entry->get_value();
  40. =head1 DESCRIPTION
  41. An object of this class represents a FCM keyword entry.
  42. =head1 METHODS
  43. =over 4
  44. =item C<new({key =E<gt> $key, value =E<gt> $value})>
  45. Constructor.
  46. =item get_key()
  47. Returns the key of this keyword entry.
  48. =item get_value()
  49. Returns the value of this keyword entry.
  50. =back
  51. Simple formatter for displaying an entry.
  52. =head1 SEE ALSO
  53. L<Fcm::Keyword|Fcm::Keyword>,
  54. L<Fcm::Keyword::Entries|Fcm::Keyword::Entries>
  55. =head1 COPYRIGHT
  56. E<169> Crown copyright Met Office. All rights reserved.
  57. =cut