File Coverage

lib/HTML/Object/DOM/TextTrackCueList.pm
Criterion Covered Total %
statement 19 32 59.3
branch 0 8 0.0
condition 0 9 0.0
subroutine 7 10 70.0
pod 3 3 100.0
total 29 62 46.7


line stmt bran cond sub pod time code
1             ##----------------------------------------------------------------------------
2             ## HTML Object - ~/lib/HTML/Object/DOM/TextTrackCueList.pm
3             ## Version v0.2.0
4             ## Copyright(c) 2021 DEGUEST Pte. Ltd.
5             ## Author: Jacques Deguest <jack@deguest.jp>
6             ## Created 2021/12/27
7             ## Modified 2022/09/18
8             ## All rights reserved
9             ##
10             ##
11             ## This program is free software; you can redistribute it and/or modify it
12             ## under the same terms as Perl itself.
13             ##----------------------------------------------------------------------------
14             package HTML::Object::DOM::TextTrackCueList;
15             BEGIN
16             {
17 1     1   990 use strict;
  1         3  
  1         31  
18 1     1   5 use warnings;
  1         3  
  1         27  
19 1     1   5 use parent qw( HTML::Object::DOM::List );
  1         4  
  1         5  
20 1     1   81 use vars qw( $VERSION );
  1         14  
  1         50  
21 1     1   39 our $VERSION = 'v0.2.0';
22             };
23              
24 1     1   7 use strict;
  1         3  
  1         23  
25 1     1   5 use warnings;
  1         2  
  1         277  
26              
27             sub init
28             {
29 0     0 1   my $self = shift( @_ );
30 0           $self->{_init_strict_use_sub} = 1;
31 0 0         $self->SUPER::init( @_ ) || return( $self->pass_error );
32 0           return( $self );
33             }
34              
35 0     0 1   sub forEach { return( shift->children->foreach( @_ ) ); }
36              
37             sub getCueById
38             {
39 0     0 1   my $self = shift( @_ );
40 0           my $id = shift( @_ );
41 0 0 0       return if( !defined( $id ) || !CORE::length( "$id" ) );
42 0           foreach my $e ( @$self )
43             {
44 0 0 0       if( Scalar::Util::blessed( $e ) &&
45             $e->isa( 'HTML::Object::DOM::TextTrackCue' ) )
46             {
47 0           my $e_id = $e->attr( 'id' );
48 0 0 0       return( $e ) if( defined( $e_id ) && $id eq $e_id );
49             }
50             }
51 0           return;
52             }
53              
54             # Note: property length is inherited from Module::Generic::Array
55              
56             1;
57             # NOTE: POD
58             __END__
59              
60             =encoding utf-8
61              
62             =head1 NAME
63              
64             HTML::Object::DOM::TextTrackCueList - HTML Object DOM TextTrack Cue List Class
65              
66             =head1 SYNOPSIS
67              
68             use HTML::Object::DOM::TextTrackCueList;
69             my $list = HTML::Object::DOM::TextTrackCueList->new ||
70             die( HTML::Object::DOM::TextTrackCueList->error, "\n" );
71              
72             =head1 VERSION
73              
74             v0.2.0
75              
76             =head1 DESCRIPTION
77              
78             The C<TextTrackCueList> represents a dynamically updating list of C<TextTrackCue> objects.
79              
80             It inherits from L<HTML::Object::DOM::List>
81              
82             =head1 INHERITANCE
83              
84             +-----------------------+ +---------------------------+ +-------------------------+ +-------------------------------------+
85             | HTML::Object::Element | --> | HTML::Object::EventTarget | --> | HTML::Object::DOM::List | --> | HTML::Object::DOM::TextTrackCueList |
86             +-----------------------+ +---------------------------+ +-------------------------+ +-------------------------------------+
87              
88             =head1 PROPERTIES
89              
90             =head2 length
91              
92             An unsigned long that is the number of cues in the list.
93              
94             Example:
95              
96             my $video = $doc->getElementById( 'video' );
97             $video->onplay = sub
98             {
99             say( $video->textTracks->[0]->cues->length ) # 5;
100             };
101              
102             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/TextTrackCueList/length>
103              
104             =head1 METHODS
105              
106             =head2 forEach
107              
108             This is an alias for L<Module::Generic::Array/foreach>
109              
110             =head2 getCueById
111              
112             Returns the first L<TextTrackCue|HTML::Object::DOM::TextTrackCue> object with the identifier passed to it.
113              
114             Example:
115              
116             my $video = $doc->getElementById( 'video' );
117             $video->onplay = sub
118             {
119             say( $video->textTracks->[0]->cues->getCueById( 'second' ) ) # a VTTCue object;
120             }
121              
122             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/TextTrackCueList/getCueById>
123              
124             =head1 AUTHOR
125              
126             Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
127              
128             =head1 SEE ALSO
129              
130             L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/TextTrackCueList>
131              
132             =head1 COPYRIGHT & LICENSE
133              
134             Copyright(c) 2021 DEGUEST Pte. Ltd.
135              
136             All rights reserved
137              
138             This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
139              
140             =cut