Commit | Line | Data |
bf5a23d0 |
1 | package HTML::Zoom::ReadFH; |
2 | |
1cf03540 |
3 | use strictures 1; |
bf5a23d0 |
4 | |
5 | sub from_zoom { |
6 | my ($class, $zoom) = @_; |
7 | bless({ _zoom => $zoom }, $class) |
8 | } |
9 | |
10 | sub to_zoom { |
11 | my $self = shift; |
12 | # A small defense against accidental footshots. I hope. |
13 | # If this turns out to merely re-aim the gun at your left nipple, please |
14 | # come complain with a documented use case and we'll discuss deleting it. |
15 | die "Already started reading - there ain't no going back now" |
16 | if $self->{_stream}; |
17 | $self->{_zoom} |
18 | } |
19 | |
20 | sub getline { |
21 | my $self = shift; |
22 | my $html; |
23 | my $stream = $self->{_stream} ||= $self->{_zoom}->to_stream; |
24 | my $producer = $self->{_producer} ||= $self->{_zoom}->zconfig->producer; |
25 | while (my ($evt) = $stream->next) { |
26 | $html .= $producer->event_to_html($evt); |
27 | last if $evt->{flush}; |
28 | } |
29 | return $html |
30 | } |
31 | |
32 | sub close { "The door shuts behind you with a ominous boom" } |
33 | |
34 | 1; |