The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Data::URIID::Result - Extractor for identifiers from URIs

VERSION

version v0.07

SYNOPSIS

    use Data::URIID;

    my $extractor = Data::URIID->new;
    my $result = $extractor->lookup( $URI );

METHODS

extractor

    my $extractor = $result->extractor;

Returns the Data::URIID object used to create this object.

id_type

    my $id_type = $result->id_type;

This method will return the ISE of the id's type if successful or die otherwise.

id

    my $id = $result->id;
    # or:
    my $id = $result->id( $type );

This method will return the id if successful or die otherwise.

ise

    my $ise = $result->ise;

This method will return the ISE if successful or die otherwise.

attribute

    my $value = $result->attribute( $key, [%opts] );

Get a attribute of the result or the default or die. Attributes are subject to the settings passed to "new" in Data::URIID. The default can be supplied via the default option (see below).

The following attributes are defined:

action

The action the original URL was using.

altitude

The altitude of the item. The reference system is not specified.

best_service

The Data::URIID::Service best used with this identifier. This is normally the service the identifier type originated from.

date_of_birth

The date of birth of the person or object.

Warning: This is an experimental attribute and may be removed or changed later!

date_of_death

The date of death of the person or object.

Warning: This is an experimental attribute and may be removed or changed later!

description

A description of the subject.

displaycolour

A colour that is commonly used to display alongside the item.

displayname

A name that can be used to display the subject to the user.

icon

An icon for the item.

icon_text

A one character alternative to the icon. This character may be any unicode character. This also implies that a) the width of the character may vary, b) may use characters outside the range of any 8 bit encoding.

latitude

The latitude of the item. The reference system is not specified.

longitude

The longitude of the item. The reference system is not specified.

media_subtype

Media subtype of the item.

Warning: This is an experimental attribute and may be removed or changed later!

roles

List of roles returned by the lookup for the subject. This attribute requires list to be set true.

service

The Data::URIID::Service the original URL was using.

sources

The list of Data::URIID::Service that returned data in the lookup. Useful to provide a bibliography. This attribute requires list to be set true.

sex_or_gender

The sex or gender of the object. This is useful when addressing people.

space_object

The object in space (astronomical body) this item is on.

thumbnail

A thumbnail image that can be used for the item.

website

A website that represents the item. For example if the item is a company the website of that company.

The following options are defined:

as

Return the value as the given type. This is the package name of the type, string for plain perl strings, or ise for an ISE. If the given type is not supported for the given attribute the function dies.

default

Returns the given value if no value is found. This can also be set to undef to allow returning undef in case of no value found instead of die-ing.

language_tags

Overrides the default language tags from the $result->extractor object. May be an arrayref with a list of exact matches or a string that is parsed as a list (and supers being added).

list

Sets the function in list mode. List mode is used for special attributes that are lists. In this mode this method will return a list. default if used needs to be set to some array reference. This mode is only available with list mode keys.

online

Overrides the "online" in Data::URIID flag used for the lookup if as is set to Data::URIID::Result. This is very useful to prevent network traffic for auxiliary lookups.

digest

    my $digest = $result->digest( $algorithm, [%opts] );

Returns a digest of the referenced file or object. This refers to the result of URLs for the fetch or file-fetch actions.

Supported algorithms depend on the providing service. Algorithm names are given in the universal tag form but aliases for names as by Digest are supported.

Common values include: md-5-128, sha-1-160, sha-2-256, and sha-3-512.

The following options are defined:

as

Return the value as the given type. This is the package name of the type, hex for hex values, or base64 (or b64) for Base64 encoding without padding and base64_padded for Base64 encoding with padding. To get an object that is compatible with the Digest API use Digest. Do not try to use specific types such as Digest::MD5. If the given type is not supported for the given attribute the function dies.

default

Returns the given value if no value is found. This can also be set to undef to allow returning undef in case of no value found instead of die-ing.

available_keys

    my @keys = $result->available_keys( $class );

Returns the list of keys available for $class. Currently attribute for keys valid for "attribute" and digest for keys valid for "digest" are supported.

The caller must not assume that all values for keys returned by this method are actually set/available. This method may return an empty list.

On any error this method will die.

url

    my $url = $result->url;
    # or:
    my $url = $result->url( $service );
    my $url = $result->url( service => $service ); # the same
    # or:
    my $url = $result->url( %options );

Returns a URL for the resource on a given service. If no service is given the value returned by $result->attribute('service') is used.

This method will return a URL (URI object) if successful or die otherwise.

The following options are defined:

action

Returns an URL for the given action. Defaults to $result->attribute('action').

service

Returns an URL for the given service. May be an service name, or Data::URIID::Service object. Defaults to $result->attribute('service').

language_tags

Overrides the default language tags from the $result->extractor object. May be an arrayref with a list of exact matches or a string that is parsed as a list (and supers being added).

AUTHOR

Löwenfelsen UG (haftungsbeschränkt) <support@loewenfelsen.net>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2023-2024 by Löwenfelsen UG (haftungsbeschränkt) <support@loewenfelsen.net>.

This is free software, licensed under:

  The Artistic License 2.0 (GPL Compatible)