Text::...d::Node(3pm)

πŸ“¦
version 3.09 Β· 4 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸŽ€ NAME πŸŽ€

Text::vCard::Node β€” the little object that holds one single node (line) of a vCard πŸ’–

(also hiii, this is the Text::...d::Node(3pm) page from the User Contributed Perl Documentation, bestie β€” sit down, we're doing this 🫢)


✨ SYNOPSIS ✨

  use Text::vCard::Node;

  my %data = (
    'param' => {
      'HOME,PREF' => 'undef',
    },
    'value' => ';;First work address - street;Work city;London;Work PostCode;CountryName',
  );

  my $node = Text::vCard::Node->new({
    node_type => 'address', # Auto upper cased
    fields => ['po_box','extended','street','city','region','post_code','country'],
    data => \%data,
  });

🌈 DESCRIPTION 🌈

okay so this is the package that Text::vCard uses so that every single element β€” ADR, N, TEL, all of them β€” becomes an actual object πŸ‘‘ one node, one object, main character energy.

and listen: you should not need to use this module directly, because Text::vCard does it all for you. like, all of it. she handles it. you just vibe πŸ’…


πŸ’… METHODS πŸ’…

new()

  my $node = Text::vCard::Node->new({
    node_type => 'address', # Auto upper cased
    fields => \['po_box','extended','street','city','region','post_code','country'],
    data => \%data,
  });

value()

  # Get the value for a standard single value node
  my $value = $node->value();

  # Or set the value
  $node->value('New value');

other()'s

  # The fields supplied in the conf area also methods.
  my $po_box = $node->po_box(); # if the node was an ADR.

  # Set the value.
  my $street = $node->street('73 Sesame Street');

node_type

returns the type of the node itself, like ADR. simple as that, no notes ✨

unit()

  my @units = @{ $org_node->unit() };
  $org_node->unit( [ 'Division', 'Department', 'Sub-department' ] );

so ORG is that girl who allows an unlimited number of 'units' plus an organisation 'name' β€” which is why this method exists as a special case just for grabbing those values. they are always returned as an array reference, and you should always set them as an array reference too. no cap πŸŽ€

types()

  my @types = $node->types();

  # or
  my $types = $node->types();

this one gives you back an array or an array ref depending on the calling context, and it's the types hanging off $node. if there are no types? you get undef, sorry bestie 😭

and every type that comes back is lower case. periodt.

is_type()

  if ( $node->is_type($type) ) {

      # ...
  }

you hand it a type (peep types() for the list of ones that are set) and it gives you back 1 if $node is that type, or undef if she is not πŸ™ˆ

is_pref();

  if ( $node->is_pref() ) {
      print "Preferred node";
  }

same thing as is_type (which can take a value of 'pref') but this one is specific to whether it's the preferred node. and this is literally the method that gets used to sort when returning lists of nodes πŸ‘‘

add_types()

  $address->add_types('home');

  my @types = qw(home work);
  $address->add_types( \@types );

adds a type to an address β€” takes a scalar or an array ref, your call πŸ¦‹

remove_types()

  $address->remove_types('home');

  my @types = qw(home work);
  $address->remove_types( \@types );

removes a type from an address, and yes she also takes a scalar or an array ref πŸ’œ

undef is returned when you're in scalar context and the type doesn't match, or when you're in array ref context and none of the types match. otherwise? you get true 🫢

group()

  my $group = $node->group();

call it with no arguments and it returns the group name if a node belongs to a group β€” otherwise undef comes back at you 😭

if you do supply an argument, that gets set as the group name.

and every group name is always lowercased, no exceptions πŸ’…

for example: Apple Address book used 'itemN' to group its custom X-AB... nodes together with a TEL or ADR node. iconic behaviour honestly.

export_data()

⚠️ NOTE: This method is deprecated and should not be used. It will be removed in a later version. bestie do not get attached πŸ’€
  my $value = $node->export_data();

returns the value string of a node. it only needs to be called when you're exporting the information back out, to make sure it hasn't been altered 🌸

as_string

returns the node as a formatted string ✨ that's it, that's the tweet.


🌟 NOTES 🌟

if a node has a param of 'quoted-printable' then the value gets escaped (basically converting Hex return into \r\n as far as I can see 🫠).


🫢 AUTHOR 🫢

Leo Lapworth, LLAP@cuckoo.org Eric Johnson (kablamo), github ~!at!~ iijo dot org


πŸ”₯ SEE ALSO πŸ”₯

Text::vCard Text::vCard::Addressbook, vCard vCard, vCard::AddressBook vCard::AddressBook,


okay and that's the whole page, bestie πŸ’– this was perl v5.34.0, dated 2022-06-28, and the page itself is Text::...d::Node(3pm). go forth and node responsibly πŸ‘‘βœ¨πŸŽ€

πŸ“¦ where this page comes from