Data::...Writer(3pm)

πŸ“¦
version 0.14 Β· 5 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu questing

πŸ¦‹ Data::Stag::Writer πŸ¦‹

hiii bestie πŸ’– so you're looking at the manual page for Data::Stag::Writer, which lives in the User Contributed Perl Documentation corner of the universe. ngl this one is a base class, which means you do not use it directly β€” you inherit from it and it does the vibes for you. let's get into it ✨


🌸 NAME 🌸

Data::Stag::Writer β€” the base class for all Writers. like, every single one. it's giving founding mother energy πŸ‘‘


✨ SYNOPSIS ✨

# Abstract class - do not use directly
package MyOutputter;
use base qw(Data::Stag::Writer);

sub e_foo {
  my ($self, $foo) = @_;
  $self->writef("data1: %s\n", $foo->get_data1);
  return;
}
🚨 ok real talk: that comment says Abstract class - do not use directly. that is not a suggestion, bestie. that is the law. you subclass it, you don't touch it raw 😭

πŸŽ€ DESCRIPTION πŸŽ€

it's a base mixin class for all writers. that's it, that's the description. she's short, she's iconic, she said what she said πŸ’…


🧚 INHERITANCE 🧚

this one inherits from L<Data::Stag::BaseHandler> β€” so all that handler energy is already in the building, no cap 🫢


πŸ‘‘ PUBLIC METHODS - πŸ‘‘

okay this is the main character section, get comfy 🌈


πŸ’œ new

  Title: new

   Args: [fn str], [fh FILEHANDLE]
 Return: L<Data::Stag::BaseHandler>
Example: $w = MyWriter->new(-fh=>$fh);

returns the tree that was built from all uncaught events 🌳

lowkey obsessed with the fact that it hands you back a Data::Stag::BaseHandler. that's the return type, fr fr.

πŸ’œ file

  Title: file

   Args: filename str
Returns: filename str
Example: $handler->file("my_output_file.txt");

setting this will cause all output to be diverted to this file; the file will be overwritten by default ⚠️ so like, don't point it at your diary. the filehandle will not be opened unless any events are thrown.

for more fine-grained control, use $handler->fh() πŸ’…


πŸ’œ fh

  Title: fh

   Args: filehandle FH
Returns: filehandle FH
Example: $handler->fh(\*STDOUT);

gets/sets the output filehandle for the writer. that's the whole thing. simple, clean, slay ✨


πŸ’œ safe_fh

  Title: safe_fh
   Type: PROTECTED

   Args: filehandle FH
Returns: filehandle FH
Example: $handler->fh(\*STDOUT);

it's literally fh(), but it makes sure that the filehandle is initialized first. no uninitialized-filehandle jumpscare 🫢

you should use this if you are overriding this class. that's not a vibe check, that's an instruction πŸ’…


πŸ’œ write

  Title: write

   Type: PROTECTED
   Args: message str
Returns:
Example: $self->write($stag->get_blah);

writes output πŸ“

to be used by classes that subclass this one. yes, that means you, bestie.

note that Returns: is just... empty. she gives nothing back. she's a giver in the writing sense only 😌

πŸ’œ writef

  Title: writef

as write, analogous to printf πŸ“


πŸ’œ use_color

Usage   -
Returns -
Args    -

that's it. that's the whole entry. three little lines, zero elaboration. she's mysterious, she's enigmatic, she's an icon πŸ’€πŸŒˆ


🌟 and that's the page 🌟

if you were looking for more detail on use_color, bestie, so was I. sometimes the documentation is a vibe, not a manual πŸ™ˆ


sending you off with love πŸ’– this page is from perl v5.34.0, dated 2022-06-12. mwah, go write something iconic, and remember: subclass it, don't use it directly πŸŽ€βœ¨πŸ’…

πŸ“¦ where this page comes from