| 1 | package Async::Stream::FromArray; | ||||||||||
| 2 | |||||||||||
| 3 | 3 | ▶ | use 5.010; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 3 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 3 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 3 | ▶ | use base qw(Async::Stream); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 3 | ▶ | use Carp qw(croak); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | =head1 NAME | ||||||||||
| 12 | |||||||||||
| 13 | Use that class for creating streams from array. | ||||||||||
| 14 | |||||||||||
| 15 | =head1 VERSION | ||||||||||
| 16 | |||||||||||
| 17 | Version 0.11 | ||||||||||
| 18 | |||||||||||
| 19 | =cut | ||||||||||
| 20 | |||||||||||
| 21 | 3 | our $VERSION = '0.12'; | |||||||||
| 22 | |||||||||||
| 23 | |||||||||||
| 24 | =head1 SYNOPSIS | ||||||||||
| 25 | |||||||||||
| 26 | use Async::Stream::FromArray; | ||||||||||
| 27 | |||||||||||
| 28 | my @domains = qw( | ||||||||||
| 29 | ucoz.com | ||||||||||
| 30 | ya.ru | ||||||||||
| 31 | googl.com | ||||||||||
| 32 | ); | ||||||||||
| 33 | |||||||||||
| 34 | my $stream = Async::Stream::FromArray->new(@domains); | ||||||||||
| 35 | |||||||||||
| 36 | =head1 SUBROUTINES/METHODS | ||||||||||
| 37 | |||||||||||
| 38 | |||||||||||
| 39 | =head2 new(@array_of_items) | ||||||||||
| 40 | |||||||||||
| 41 | Constructor creates instance of class. | ||||||||||
| 42 | Class method gets a list of items which are used for generating stream's items. | ||||||||||
| 43 | |||||||||||
| 44 | my @domains = qw( | ||||||||||
| 45 | ucoz.com | ||||||||||
| 46 | ya.ru | ||||||||||
| 47 | googl.com | ||||||||||
| 48 | ); | ||||||||||
| 49 | |||||||||||
| 50 | my $stream = Async::Stream::FromArray->new(@urls) | ||||||||||
| 51 | |||||||||||
| 52 | =cut | ||||||||||
| 53 | |||||||||||
| 54 | 36 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 55 | 36 | my $class = shift; | |||||||||
| 56 | 36 | my $items = \@_; | |||||||||
| 57 | |||||||||||
| 58 | return $class->SUPER::new( | ||||||||||
| 59 | 145 | ▶ | sub { | ||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||
| 60 | 145 | ▶ | $_[0]->( @{$items} ? (shift @{$items}) : () ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 61 | 145 | return; | |||||||||
| 62 | } | ||||||||||
| 63 | 36 | ); | |||||||||
| 64 | } | ||||||||||
| 65 | |||||||||||
| 66 | |||||||||||
| 67 | =head1 AUTHOR | ||||||||||
| 68 | |||||||||||
| 69 | Kirill Sysoev, C<< <k.sysoev at me.com> >> | ||||||||||
| 70 | |||||||||||
| 71 | =head1 BUGS AND LIMITATIONS | ||||||||||
| 72 | |||||||||||
| 73 | Please report any bugs or feature requests to | ||||||||||
| 74 | L<https://github.com/pestkam/p5-Async-Stream/issues>. | ||||||||||
| 75 | |||||||||||
| 76 | =head1 SUPPORT | ||||||||||
| 77 | |||||||||||
| 78 | You can find documentation for this module with the perldoc command. | ||||||||||
| 79 | |||||||||||
| 80 | perldoc Async::Stream::Item | ||||||||||
| 81 | |||||||||||
| 82 | |||||||||||
| 83 | =head1 LICENSE AND COPYRIGHT | ||||||||||
| 84 | |||||||||||
| 85 | Copyright 2017 Kirill Sysoev. | ||||||||||
| 86 | |||||||||||
| 87 | This program is free software; you can redistribute it and/or modify it | ||||||||||
| 88 | under the terms of the the Artistic License (2.0). You may obtain a | ||||||||||
| 89 | copy of the full license at: | ||||||||||
| 90 | |||||||||||
| 91 | L<http://www.perlfoundation.org/artistic_license_2_0> | ||||||||||
| 92 | =cut | ||||||||||
| 93 | |||||||||||
| 94 | 3 | 1; # End of Async::Stream::FromArray | |||||||||