RoPkg:...::Atom(3pm)

πŸ“¦ version 0.4, in ubuntu jammy

πŸ’– NAME πŸ’–

okay bestie, welcome to the RoPkg:...::Atom(3pm) page β€” user contributed perl documentation, the whole vibe πŸ’…

RoPkg::Rsync::Atom β€” it's literally the smallest unit in a rsync configuration file. tiny but iconic πŸŽ€


✨ SYNOPSIS ✨

no cap, here's how you'd actually use it:

#!/usr/bin/perl

use strict;
use warnings;

use RoPkg::Rsync::Atom;

sub main {
  my $a = new RoPkg::Rsync::Atom(
                type  => 'param',
                name  => 'uid',
                value => 'nobody',
              );

  print $a->ToString(0),$/;

  return 0;
}

main();

🌸 DESCRIPTION 🌸

so RoPkg::Rsync::Atom is a class that the RoPkg::Rsync modules use. the Atom is giving "smallest part of any rsync configuration file" energy β€” like, the little atom of the whole thing, iykyk 🧚

an atom can be (at this moment):

  • param
  • blank
  • comment

πŸ‘‘ METHODS πŸ‘‘

okay so important thing first: all the methods throw the OutsideClass exception if you use them as class methods. not it.

example:

perl -MRoPkg::Rsync::Atom -e 'RoPkg::Rsync::Atom->Type;'
Called outside class instance

and besides OutsideClass, the methods are throwing other exceptions too 😭 refer to each method's own documentation for the deets.


πŸŽ€ new() πŸŽ€

the constructor of the class, the main character fr. new accepts 3 parameters grouped inside a hash:

  • *) type β€” type of the atom
  • *) name β€” name of the atom
  • *) value β€” value of the atom

the type parameter must always be present. if type is not present, a Param::Missing exception is raised 🚨

at this moment, the atoms have 3 types:

  • *) param β€” a parameter in the standard form (name = value)
  • *) comment β€” a comment
  • *) blank β€” a blank line (or only with separators)

and if the value of the type parameter is not one of the ones specified, a Param::Wrong exception is raised πŸ’€

examples, bestie:

example 1 (param):

my $a = new RoPkg::Rsync::Atom(
              type  => 'param',
              name  => 'gid',
              value => 'users',
            );

example 2 (param):

my $a = new RoPkg::Rsync::Atom(type => 'param');
$a->Name('gid');
$a->Value('users');
print 'Name of the atom is:',$a->Name,$/;

example 3 (comment):

my $a = new RoPkg::Rsync::Atom(
              type  => 'comment',
              value => '# this is the group id',
            );

example 4 (blank):

my $a = new RoPkg::Rsync::Atom(
              type  => 'blank',
              value => q{ },
            );

πŸ’… Name($new_name)

the Name method is a get/set method β€” she does both, versatile queen ✨ if $new_name exists (and his value is defined) then the set behaviour is selected, otherwise the method acts as a get method. returns the name of the atom 🫢


πŸ¦‹ Value($new_value)

the Value method is a get/set method too. if $new_value exists (and his value is defined) then the set behaviour is selected, otherwise the method acts as a get method. returns the value of the atom πŸ’–


⭐ ToString($indent, $spaces)

returns the string representation of the atom. accepts 2 parameters: indent and spaces.

$indent is a true/false value specifing that the string representation should be prefixed with a tab character; $spaces is used to compute the number of spaces that should be added after the atom name, so that the total length of the parameter name to match the $spaces value. lowkey satisfying to watch it line up ngl πŸ“

example:

my $a = new RoPkg::Rsync::Atom(
              type  => 'param',
              name  => 'gid',
              value => 'users',
            );

print $a->ToString(0, 6),$/,
      $a->ToString(0, 5),$/,
      $a->ToString(0, 4),$/,
      $a->ToString(0, 3),$/,
      $a->ToString(1, 6),$/,
      $a->ToString(1, 5),$/,
      $a->ToString(1, 4),$/,
      $a->ToString(1, 3),$/;

the result is:

gid    = users
gid   = users
gid  = users
gid = users
       gid    = users
       gid   = users
       gid  = users
       gid = users

🌈 Type

returns the type (string representation) of the atom. short, sweet, slay πŸŽ€


πŸ“ PREREQUISITES πŸ“

perl 5.008 (or later) is required. besides perl, you must have the following:

  • RoPkg::Exceptions
  • English
  • Scalar::Util

πŸ”₯ SEE ALSO πŸ”₯

RoPkg::Rsync::Node RoPkg::Rsync::ConfFile RoPkg::Exceptions


πŸ’œ AUTHOR πŸ’œ

Subredu Manuel <diablo@iasi.roedu.net> β€” ty for your service king 🫢


🧚 LICENSE 🧚

Copyright (C) 2005 Subredu Manuel. All Rights Reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The LICENSE file contains the full text of the license.


okay that's the whole page bestie, you ate that πŸ’… this was perl v5.32.1, dated 2021-12-26 β€” and that's the RoPkg:...::Atom(3pm) vibe check, periodt πŸ’–βœ¨πŸŒˆ
πŸ“¦ where this page comes from