summaryrefslogtreecommitdiff
path: root/fml/lib/FML/String
diff options
context:
space:
mode:
authorfukachan <fukachan>2008-09-10 03:49:59 +0000
committerfukachan <fukachan>2008-09-10 03:49:59 +0000
commit1a75c97abc0e59b8b507f82f4066e256cd0d5562 (patch)
treef1b750b8d9702bce071aebe6c7df926fc1109b0e /fml/lib/FML/String
parent0c9d0892c7e8cbca0749811266edac5e96cafc92 (diff)
downloadfml8-1a75c97abc0e59b8b507f82f4066e256cd0d5562.tar.gz
fml8-1a75c97abc0e59b8b507f82f4066e256cd0d5562.tar.bz2
fml8-1a75c97abc0e59b8b507f82f4066e256cd0d5562.zip
new() needs $curproc as the argument.
as_png() checks if GD perl module is available. if not, return undef.
Diffstat (limited to 'fml/lib/FML/String')
-rw-r--r--fml/lib/FML/String/Banner.pm32
1 files changed, 25 insertions, 7 deletions
diff --git a/fml/lib/FML/String/Banner.pm b/fml/lib/FML/String/Banner.pm
index 31bc9f61..d877609f 100644
--- a/fml/lib/FML/String/Banner.pm
+++ b/fml/lib/FML/String/Banner.pm
@@ -4,7 +4,7 @@
# All rights reserved. This program is free software; you can
# redistribute it and/or modify it under the same terms as Perl itself.
#
-# $FML: @template.pm,v 1.12 2008/08/24 08:28:36 fukachan Exp $
+# $FML: Banner.pm,v 1.1 2008/09/09 02:59:03 fukachan Exp $
#
package FML::String::Banner;
@@ -66,14 +66,14 @@ constructor.
# Descriptions: constructor.
-# Arguments: OBJ($self)
+# Arguments: OBJ($self) OBJ($curproc)
# Side Effects: none
# Return Value: OBJ
sub new
{
- my ($self) = @_;
+ my ($self, $curproc) = @_;
my ($type) = ref($self) || $self;
- my $me = {};
+ my $me = { _curproc => $curproc };
srand(time|$$);
@@ -192,11 +192,29 @@ file at the caller side.
sub as_png
{
my ($self, $string) = @_;
+ my ($curproc) = $self->{ _curproc };
my ($_string) = $self->get_string() || $string;
- use FML::String::Banner::Image;
- my $banner = new FML::String::Banner::Image;
- return $banner->as_png($_string);
+ eval q{
+ use GD;
+ };
+ if ($@) {
+ $curproc->logwarn("cannot load GD perl module.");
+ $curproc->logwarn("install p5-GD from package system on your OS");
+ }
+
+ my $banner = undef;
+ eval q{
+ use FML::String::Banner::Image;
+ $banner = new FML::String::Banner::Image;
+ };
+ unless ($@) {
+ if (defined $banner) {
+ return $banner->as_png($_string);
+ }
+ }
+
+ return undef;
}