Leo Lapworth > Text-vCard-2.13 > Text::vCard::Node

Download:
Text-vCard-2.13.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 2.13   Source   Latest Release: Text-vCard-3.06

NAME ^

Text::vCard::Node - Object for each node (line) of a vCard

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 ^

Package used by Text::vCard so that each element: ADR, N, TEL etc are objects.

You should not need to use this module directly, Text::vCard does it all for you.

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, e.g. ADR.

unit()

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

As ORG allows unlimited numbers of 'units' as well as and organisation 'name', this method is a specific case for accessing those values, they are always returned as an array reference, and should always be set as an array reference.

types()

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

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

This method will return an array or an array ref depending on the calling context of types associated with the $node, undef is returned if there are no types.

All types returned are lower case.

is_type()

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

      # ...
  }

Given a type (see types() for a list of those set) this method returns 1 if the $node is of that type or undef if it is not.

is_pref();

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

This method is the same as is_type (which can take a value of 'pref') but it specific to if it is the prefered node. This method is used to sort when returning lists of nodes.

add_types()

  $address->add_types('home');

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

Add a type to an address, it can take a scalar or an array ref.

remove_types()

  $address->remove_types('home');

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

This method removes a type from an address, it can take a scalar or an array ref.

undef is returned when in scalar context and the type does not match, or when in array ref context and none of the types match, true is returned otherwise.

group()

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

If called without any arguments, this method returns the group name if a node belongs to a group. Otherwise undef is returned.

If an argument is supplied then this is set as the group name.

All group names are always lowercased.

For example, Apple Address book used 'itemN' to group it's custom X-AB... nodes with a TEL or ADR node.

export_data()

  my $value = $node->export_data();

This method returns the value string of a node. It is only needs to be called when exporting the information back out to ensure that it has not been altered.

as_string

Returns the node as a formatted string.

NOTES

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

EXPORT

None by default.

AUTHOR ^

Leo Lapworth, LLAP@cuckoo.org

SEE ALSO ^

Text::vCard Text::vCard::Addressbook

syntax highlighting: