NAME

Mobile::UserAgentFactory - Instantiates and caches Mobile::UserAgent objects.

SYNOPSIS

use Mobile::UserAgentFactory;
my $factory = Mobile::UserAgentFactory->instance();

# Get Mobile::UserAgent object using a useragent string (preferred):
my $mua = $factory->getMobileUserAgent($ENV{'HTTP_USER_AGENT'});

# Get Mobile::UserAgent object by letting the factory look for the useragent in
# the HTTP_* environment variables.
my $mua = $factory->getMobileUserAgent();

if (defined($mua) && $mua->success()) {
  printf("Vendor: %s\nModel: %s\n", $mua->vendor(), $mua->model());
}

DESCRIPTION

Factory class for the instantiating and caching of Mobile::UserAgent objects. Caching occurs in this class itself.

CONSTRUCTOR

$factory = Mobile::UserAgentFactory->instance($options_hash_ref)

This class method returns a Mobile::UserAgentFactory instance.

The optional $options_hash_ref supports the following options:

cache_expires_in - The expiration time for unused Mobile::UserAgent objects in the internal cache. Defaults to 86400 (1 day) if not explicitly set.

cache_purge_interval - Sets the internal cache purge interval. Defaults to 3600 (1 hour).

cache_max_age - Sets the maximum time Mobile::UserAgent objects may remain in the internal cache. Defaults to 604800 (1 week).

cache_max_objects - Sets the maximum number of objects to store in the internal cache. Defaults to 1000.

PUBLIC OBJECT METHODS

The public object methods available are:

$uaprof->getMobileUserAgent([$useragent | $cgi], [$options])

Returns a matching Mobile::UserAgent object or undef if none could be found.

You can optionally pass either a $useragent string or a CGI object as first parameter. If you pass neither, then this method will attempt to use the HTTP_USER_AGENT environment variable.

$options is an optional hash ref which may contain the following keys:

debug - Set it to a true value to see what's going on.

SEE ALSO

Mobile::UserAgent.

COPYRIGHT

Copyright (C) 2005 Craig Manley. All rights reserved. You may not redistribute, sell, modify, copy, claim ownership of, nor incorporate this software into any other software without the prior written permission of the author. This software may only be used in applications developed by the author.

AUTHOR

Craig Manley