source: branches/UKMO/r6232_tracer_advection/NEMOGCM/EXTERNAL/fcm/lib/Fcm/Interactive/InputGetter.pm @ 9295

Last change on this file since 9295 was 9295, checked in by jcastill, 3 years ago

Remove svn keywords

File size: 3.0 KB
Line 
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# ------------------------------------------------------------------------------
6use strict;
7use warnings;
8
9package Fcm::Interactive::InputGetter;
10
11use Carp qw{croak};
12
13################################################################################
14# Constructor
15sub new {
16    my ($class, $args_ref) = @_;
17    return bless({%{$args_ref}}, $class);
18}
19
20################################################################################
21# Methods: get_*
22for my $key (
23    ############################################################################
24    # Returns the title of the prompt
25    'title',
26    ############################################################################
27    # Returns the message of the prompt
28    'message',
29    ############################################################################
30    # Returns the of the prompt
31    'type',
32    ############################################################################
33    # Returns the default return value
34    'default',
35) {
36    no strict qw{refs};
37    my $getter = "get_$key";
38    *$getter = sub {
39        my ($self) = @_;
40        return $self->{$key};
41    }
42}
43
44################################################################################
45# Invokes the getter
46sub invoke {
47    my ($self) = @_;
48    croak("Fcm::Interactive::InputGetter->invoke() not implemented.");
49}
50
511;
52__END__
53
54=head1 NAME
55
56Fcm::Interactive::TxtInputGetter
57
58=head1 SYNOPSIS
59
60    use Fcm::Interactive::TxtInputGetter;
61    $answer = Fcm::Interactive::get_input(
62        title   => 'My title',
63        message => 'Would you like to ...?',
64        type    => 'yn',
65        default => 'n',
66    );
67
68=head1 DESCRIPTION
69
70An object of this abstract class is used by
71L<Fcm::Interactive|Fcm::Interactive> to get a user reply.
72
73=head1 METHODS
74
75=over 4
76
77=item new($args_ref)
78
79Constructor, normally invoked via L<Fcm::Interactive|Fcm::Interactive>.
80
81Input options are: I<title>, for a short title of the prompt, I<message>, for
82the message prompt, I<type> for the prompt type, and I<default> for the default
83value of the return value.
84
85Prompt type can be YN (yes or no), YNA (yes, no or all) or input (for an input
86string).
87
88=item get_title()
89
90Returns the title of the prompt.
91
92=item get_message()
93
94Returns the message of the prompt.
95
96=item get_type()
97
98Returns the type of the prompt, can be YN (yes or no), YNA (yes, no or all) or
99input (for an input string).
100
101=item get_default()
102
103Returns the default return value of invoke().
104
105=item invoke()
106
107Gets an input string from the user, and returns it. Sub-classes must override
108this method.
109
110=back
111
112=head1 SEE ALSO
113
114L<Fcm::Interactive|Fcm::Interactive>,
115L<Fcm::Interactive::TxtInputGetter|Fcm::Interactive::TxtInputGetter>,
116L<Fcm::Interactive::GUIInputGetter|Fcm::Interactive::GUIInputGetter>
117
118=head1 COPYRIGHT
119
120E<169> Crown copyright Met Office. All rights reserved.
121
122=cut
Note: See TracBrowser for help on using the repository browser.