NAME

Image::Randim::Source - Pull a random image from a source

SYNOPSIS

use Image::Randim::Source;

$source = Image::Randim::Source->new;
$source->set_random_provider;
$image = $source->get_image;

say $image->url;

DESCRIPTION

This is the main class to instantiate when wanting to pull random image information from the defined sources.

You can specifically state which source to use to pull a random image from by using the set_provider() method, or you can also let the provider be a random choice too by calling the method set_random_provider() instead.

Nothing much will work until you call one of those two methods, except for list(), which returns a list of defined sources (providers of images).

METHODS

list

Return a list of supported providers (ones with "plugins").

set_provider($provider_name)

Sets the provider name to use, to grab a random image. Valid ones can be found with the list() method.

"Plugins" can be created to support more providers by implementing the Image::Randim::Source::Role

set_random_provider(['name1', 'name2'])

Without any parameters, chooses a random provider from the list() of possible providers and set_provider()'s to it.

An array ref - a list of source providers names - can be provided if you want to limit the random choice to just those providers.

url

Returns the URL from which the provider information is gathered. You probably don't need to care about this.

name

Returns the provider name (as it was set by set_provider())

get_image

Returns an Image::Randim::Image object, populated with the necessary information to download the image, and image credits for the owner of the image, as well as reported dimensions of the image.

ATTRIBUTES

timeout

Gets or sets the timeout in seconds we will wait for a response from the provider's server for the information. If you want something different than the default (25 seconds) you must set this attribute before calling the set_* methods.

src_obj

Gives access to the provider "plugin" object directly. Not typically needed.

AUTHOR

Mark Rushing <mark@orbislumen.net>

COPYRIGHT AND LICENSE

This software is copyright (c) 2017 by Home Grown Systems, SPC.

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