summaryrefslogtreecommitdiff
path: root/fml/lib/IO/Adapter/Array.pm
diff options
context:
space:
mode:
authorfukachan <fukachan>2002-01-27 13:11:57 +0000
committerfukachan <fukachan>2002-01-27 13:11:57 +0000
commitcd17f7899482fbcb118114a9b83cfb33db1520af (patch)
tree6d46915cd61bb3e763fc62c5c465fc31acbd4f9f /fml/lib/IO/Adapter/Array.pm
parent81cabe0bc65a6659185b73301b332653af03f67e (diff)
downloadfml8-cd17f7899482fbcb118114a9b83cfb33db1520af.tar.gz
fml8-cd17f7899482fbcb118114a9b83cfb33db1520af.tar.bz2
fml8-cd17f7899482fbcb118114a9b83cfb33db1520af.zip
clarify IO::Adapter definition and clean up get_XXX() functions.
remove get_member(), get_active() and get_recipient() define get_next_key() and get_next_value() and clarify thier definitions.
Diffstat (limited to 'fml/lib/IO/Adapter/Array.pm')
-rw-r--r--fml/lib/IO/Adapter/Array.pm37
1 files changed, 28 insertions, 9 deletions
diff --git a/fml/lib/IO/Adapter/Array.pm b/fml/lib/IO/Adapter/Array.pm
index 741850bb..52718957 100644
--- a/fml/lib/IO/Adapter/Array.pm
+++ b/fml/lib/IO/Adapter/Array.pm
@@ -1,10 +1,10 @@
#-*- perl -*-
#
-# Copyright (C) 2001 Ken'ichi Fukamachi
+# Copyright (C) 2001,2002 Ken'ichi Fukamachi
# All rights reserved. This program is free software; you can
# redistribute it and/or modify it under the same terms as Perl itself.
#
-# $FML: Array.pm,v 1.20 2001/12/22 09:21:12 fukachan Exp $
+# $FML: Array.pm,v 1.21 2001/12/24 07:40:56 fukachan Exp $
#
package IO::Adapter::Array;
@@ -22,15 +22,22 @@ IO::Adapter::Array - base class for IO emulation for the ARRAY
use IO::Adapter::Array;
- $map = [ 1, 2, 3 ];
+ $map = [ 'rudo', 'kenken', 'hitomi' ];
$obj = new IO::Adapter::Array $map;
$obj->open;
- while ($x = $obj->get_next_value) { print $x;}
+ while ($x = $obj->get_next_key) { print $x;}
$obj->close;
=head1 DESCRIPTION
emulate IO operation for the ARRAY.
+One array is similar to a set of primary keys without optional values
+such as a file:
+
+ rudo
+ kenken
+ hitomi
+ ...
=head1 METHODS
@@ -103,25 +110,31 @@ sub open
the same as get_next_value().
-=item C<get_next_value()>
+=item C<get_next_key()>
return the next element of the array
+=item C<get_next_value()>
+
+undef. ambigous in array case.
+
=cut
-# Descriptions: forwarded to get_next_value()
+# Descriptions: forwarded to get_next_key()
+# XXX getline() == get_next_key() is valid in this case.
+# XXX since this map has only key and no value.
# Arguments: OBJ($self) HASH_REF($args)
# Side Effects: increment the counter in the object
# Return Value: STR(the next element)
-sub getline { get_next_value(@_);}
+sub getline { get_next_key(@_);}
# Descriptions: return the next element of the array
# Arguments: OBJ($self) HASH_REF($args)
# Side Effects: increment the counter in the object
# Return Value: STR(the next element)
-sub get_next_value
+sub get_next_key
{
my ($self, $args) = @_;
my $i = $self->{_counter}++;
@@ -130,6 +143,12 @@ sub get_next_value
}
+sub get_next_value
+{
+ return undef;
+}
+
+
=head2 C<getpos()>
return the current position in the array
@@ -203,7 +222,7 @@ Ken'ichi Fukamachi
=head1 COPYRIGHT
-Copyright (C) 2001 Ken'ichi Fukamachi
+Copyright (C) 2001,2002 Ken'ichi Fukamachi
All rights reserved. This program is free software; you can
redistribute it and/or modify it under the same terms as Perl itself.