Toby Inkster > HTML-Microformats > HTML::Microformats::Format

Download:
HTML-Microformats-0.105.tar.gz

Dependencies

Annotate this POD

Website

CPAN RT

Open  2
View/Report Bugs
Module Version: 0.105   Source  

NAME ^

HTML::Microformats::Format - base microformat class

DESCRIPTION ^

HTML::Microformats::Format cannot be instantiated directly but many other classes inherit from it.

Constructors

The constructors cannot actually be called on this package. Call them on descendent classes instead.

$object = HTML::Microformats::Format->new($element, $context, %options)

Parse a microformat with root element $element.

$object = HTML::Microformats::Format->extract_all($element, $context, %options)

Find and parse all such microformats within element $element.

Public Methods - Accessors

There are a number of property accessor methods defined via Perl's AUTOLOAD mechanism.

For any microformat property (e.g. 'fn' in hCard) there are get_X, set_X, add_X and clear_X methods defined.

get_X: for singular properties, returns the value of property X. For plural properties, returns a list of values if called in list context, or the first value otherwise.

set_X: for singular properties, sets the value of property X to the first given parameter. For plural properties, sets the values of property X to the list of parameters. This feature is deprecated and will be removed in a future release.

add_X: for singular properties, sets the value of property X to the first given parameter, but croaks if X is already set. For concatenated singular properties, concatenates to the end of any existing value of X. For plural properties, adds any given parameters to the list of values of property X. This feature is deprecated and will be removed in a future release.

clear_X: removes any values of property X, but croaks if the property is a required property. This feature is deprecated and will be removed in a future release.

For example, an HTML::Microformats::hCard object will have a method called get_fn which gets the value of the hCard's "fn" property, a method called set_fn which sets it, a method called add_fn which also sets it (but croaks if it's already set), and a method called clear_fn which croaks if called (because "fn" is a required property).

Deprecated features: the set_X, add_X and clear_X methods are deprecated and will be removed soon. In general you should treat objects which are instances of HTML::Microformats::Format as read-only.

Public Methods - Other

$object->format_signature or $class->format_signature

This method may be called as a class or object method. It returns various information about the definition of this microformat (e.g. what is the root class, which properties exist, etc). You may need to do some digging to figure out what everything means.

$object->profiles or $class->profiles

This method may be called as a class or object method. It returns HTML profile URIs which indicate the presence of this microformat.

$object->context

Returns the parsing context (as supplied to new).

$object->data

Returns a hashref of object data. This is a reference to the live data inside the object. Any changes to the returned hashref will change the values inside the object.

$object->element

Returns the root element.

$object->cache

Shortcut for $object->context->cache.

$object->id([$trine_obj], [$role])

Returns a blank node identifier or identifying URI for the object.

If $trine_obj is true, the return value is an RDF::Trine::Node object. Otherwise, it's a string (using the '_:' convention to identify blank nodes).

If $role is undefined, then returns the identifier for the object itself. If it's defined then it returns an identifier for a resource with a fixed relationship to the object.

  $identifier_for_business_card  = $hcard->id;
  $identifier_for_person         = $hcard->id(undef, 'holder');
$object->add_to_model($model)

Given an RDF::Trine::Model object, adds relevant data to the model.

$object->model

Creates a fresh, new RDF::Trine::Model object, containing relevant data.

$object->serialise_model(as => $format)

As model but returns a string.

BUGS ^

Please report any bugs to http://rt.cpan.org/.

SEE ALSO ^

HTML::Microformats.

AUTHOR ^

Toby Inkster <tobyink@cpan.org>.

COPYRIGHT AND LICENCE ^

Copyright 2008-2012 Toby Inkster

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

DISCLAIMER OF WARRANTIES ^

THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.

syntax highlighting: