REPL client for use with automated code generation rather than user I/O.
[thrasher.git] / perl / lib / Net / REPL / Client / Queue.pm
blob96c5a5e9d7a9fa1bfdb769fe6063837799295506
1 package Net::REPL::Client::Queue;
2 use strict;
3 use warnings;
5 use base qw(Net::REPL::Client);
7 sub new {
8 my $proto = shift;
9 my $class = ref($proto) || $proto;
10 my $self = $class->SUPER::new(
11 'input_queue' => [],
12 'output_queue' => [],
13 @_,
15 return $self;
18 sub queue_input {
19 my ($self, $input) = @_;
20 push(@{$self->{'input_queue'}}, $input);
23 sub setup_io {
24 my ($self) = @_;
26 $self->{'out_fh'} = \*STDOUT;
29 sub read {
30 my ($self) = @_;
31 return shift(@{$self->{'input_queue'}})
34 sub print {
35 my ($self, @output) = @_;
37 push(@{$self->{'output_queue'}}, @output);