RDF::vCard::Line(3pm)

πŸ“¦
version 0.012 Β· 4 versions
, in debian bookworm, ubuntu noble

πŸ’– RDF::vCard::Line πŸ’–

okay so bestie, welcome to RDF::vCard::Line β€” the Perl module that's literally just one line. well, one line of a vCard. it's giving tiny but mighty, fr fr. ✨


🌸 NAME 🌸

RDF::vCard::Line β€” represents a line within a vCard πŸŽ€


πŸ¦‹ DESCRIPTION πŸ¦‹

so like, every object you make from this class corresponds to one single line inside a vCard. and lowkey? it could also be used as the basis for other RFC 2425-based formats, like iCalendar. versatile queen behavior honestly πŸ‘‘

✨ Constructor ✨

  • new(%options) β€” returns a brand new RDF::vCard::Line object, fresh out the box, no cap.

the only options you actually need to worry about are these three:

  • property β€” the property name, and it's case-insensitive so don't stress about capitalization
  • value β€” an arrayref, or just a single string if you're feeling simple
  • type_parameters β€” a hashref of property-related parameters

now here's the cute part: RDF::vCard::Entity overloads stringification, so you can literally do this:

my $line = RDF::vCard::Line->new(
  property        => 'email',
  value           => 'joe@example.net',
  type_parameters => { type=>['PREF','INTERNET'] },
  );
print "$line\n" if $line =~ /internet/i;

like?? it just stringifies and you can regex it. iconic. 🫢

πŸ’… Methods πŸ’…

  • to_string() β€” formats the line according to RFC 2425 and RFC 2426. that's it, that's the job. slay.
  • add_to_model($model, $node) β€” hand it an RDF::Trine::Model plus an RDF::Trine::Node that represents the entity (i.e. the vcard) this line belongs to, and it'll add triples to the model for this line. teamwork makes the dream work πŸ’–
  • property() β€” returns the line's property, like "EMAIL". simple, elegant, no notes.
  • property_node() β€” returns the line's property as an RDF::Trine::Node that you can use as an RDF predicate. heads up though: it returns undef if a sensible URI cannot be found. so like, check for that bestie 😭
  • property_order() β€” returns a string you can use to sort a list of lines into a sensible order. organizational queen πŸŽ€
  • value() β€” returns an arrayref for the value. each item in that arrayref could be a plain scalar, OR an arrayref of scalars. messy? a little. iconic? absolutely.

for example, the arrayref representing this name:

N:Smith;John;Edward,James

which is the vCard representation of somebody with surname Smith, given name John, and additional names (middle names) Edward and James β€” might be represented with this value arrayref:

[
  'Smith',
  'John',
  ['Edward', 'James'],
]

or maybe:

[
  ['Smith'],
  'John',
  ['Edward', 'James'],
]

see how the vibes differ?? that's exactly why it's sometimes useful to have a normalised version of it... πŸ‘€

  • nvalue() β€” returns a normalised version of the arrayref for the value. it will always be an arrayref of arrayrefs. for example:
[
  ['Smith'],
  ['John'],
  ['Edward', 'James'],
]

consistent. predictable. main character energy. ✨

  • value_node() β€” returns the line's value as an RDF::Trine::Node that can be used as an RDF object. but ngl, for some complex properties (e.g. ADR, GEO, ORG, N, etc) the result is not especially useful. so like, manage your expectations babe πŸ’€
  • value_to_string() β€” formats the line value according to RFC 2425 and RFC 2426. twin of to_string() but for the value side. πŸ’œ
  • type_parameters() β€” returns the type_parameters hashref. here be monsters (kinda). πŸ™ˆ

🌈 SEE ALSO 🌈

  • RDF::vCard

πŸ‘‘ AUTHOR πŸ‘‘

Toby Inkster <tobyink@cpan.org>.


Copyright 2011 Toby Inkster

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


and that's the whole page bestie, no cap β€” perl v5.34.0, dated 2022-06-17, which is literally ancient history in internet years but the code still eats πŸ’…βœ¨πŸ¦‹

πŸ“¦ where this page comes from