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


Mobile-UserAgent documentation  | view source Contained in the Mobile-UserAgent distribution.

Index


NAME

Top

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

SYNOPSIS

Top

 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

Top

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

CONSTRUCTOR

Top

$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

Top

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

Top

Mobile::UserAgent.

COPYRIGHT

Top

AUTHOR

Top

Craig Manley


Mobile-UserAgent documentation  | view source Contained in the Mobile-UserAgent distribution.