Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

spoon::base(3pm) [debian man page]

Spoon::Base(3pm)					User Contributed Perl Documentation					  Spoon::Base(3pm)

NAME
Spoon::Base - Generic Spoon Base Class SYNOPSIS
use Spoon::Base '-Base'; DESCRIPTION
Base class for application plugins. Provides basic functionality to all modules inheriting from this class. SUBROUTINES
These subroutines are meant to be called bare, not as an object-method call. trace See Spoon::Trace::trace(). conf(name, default) Returns the configuration value for "name", if it can be found in the config ($self->hub->config). Returns $default, otherwise. METHODS
hub Return the application's hub object. See Spoon::Hub. init Inherited by all subclasses. Put your class initialization stuff here. assert(boolean) Die if the supplied argument is false. t([label]) Calls Spoon::Trace::mark(). See Spoon::Trace. clone Copies a class instance. The copy is only a shallow one. is_in_cgi Returns a boolean, indicating whether we were called from a CGI interface. is_in_test Returns a boolean, indicating whether we were called from a test suite. have_plugin(class_id) Tries to load a plugin. See Spoon::Hub::load_class(). plugin_directory Returns your plugin's directory. You can use this directory to store state. env_check(variable_name) Sanity check: ensure the specified variable exists in %ENV. If the variable is not found, dies with a useful error message. dumper_to_file(filepath, variable1 [, variable2...]) Uses Data::Dumper to save a dump of one or more variables to the specified file. has_utf8 Returns a boolean, indicating whether utf8 is available on this platform and version of perl. utf8_encode(string) Encodes the string in utf8, if utf8 is available. Otherwise, returns $string unmodified. See Encode::encode(). utf8_decode(string) Decodes the string from utf8, if utf8 is available. Otherwise, returns $string unmodified. See Encode::decode(). uri_escape(string) Escapes all invalid URI characters. See CGI::Util::escape(). uri_unescape(string) Unescapes all invalid URI characters. See CGI::Util::unescape(). html_escape(string) Escapes all reserved characters. The result is suitable for including verbatim in an HTML document. See CGI::escapeHTML(). html_unescape(string) Escapes all reserved characters. The result is suitable for including verbatim in an HTML document. See CGI::unescapeHTML(). base64_encode(string) Encodes the specified string into Base64. See MIME::Base64::encode_base64(). base64_encode(base64_data) Decodes the specified data from Base64. See MIME::Base64::decode_base64(). TODO
* Document what Spoon::Base->debug() does. AUTHOR
Brian Ingerson <INGY@cpan.org> COPYRIGHT
Copyright (c) 2004. Brian Ingerson. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://www.perl.com/perl/misc/Artistic.html perl v5.12.4 2006-11-09 Spoon::Base(3pm)

Check Out this Related Man Page

Encode::Encoder(3)					User Contributed Perl Documentation					Encode::Encoder(3)

NAME
Encode::Encoder -- Object Oriented Encoder SYNOPSIS
use Encode::Encoder; # Encode::encode("ISO-8859-1", $data); Encode::Encoder->new($data)->iso_8859_1; # OOP way # shortcut use Encode::Encoder qw(encoder); encoder($data)->iso_8859_1; # you can stack them! encoder($data)->iso_8859_1->base64; # provided base64() is defined # you can use it as a decoder as well encoder($base64)->bytes('base64')->latin1; # stringified print encoder($data)->utf8->latin1; # prints the string in latin1 # numified encoder("x{abcd}x{ef}g")->utf8 == 6; # true. bytes::length($data) ABSTRACT
Encode::Encoder allows you to use Encode in an object-oriented style. This is not only more intuitive than a functional approach, but also handier when you want to stack encodings. Suppose you want your UTF-8 string converted to Latin1 then Base64: you can simply say my $base64 = encoder($utf8)->latin1->base64; instead of my $latin1 = encode("latin1", $utf8); my $base64 = encode_base64($utf8); or the lazier and more convoluted my $base64 = encode_base64(encode("latin1", $utf8)); Description Here is how to use this module. o There are at least two instance variables stored in a hash reference, {data} and {encoding}. o When there is no method, it takes the method name as the name of the encoding and encodes the instance data with encoding. If successful, the instance encoding is set accordingly. o You can retrieve the result via ->data but usually you don't have to because the stringify operator ("") is overridden to do exactly that. Predefined Methods This module predefines the methods below: $e = Encode::Encoder->new([$data, $encoding]); returns an encoder object. Its data is initialized with $data if present, and its encoding is set to $encoding if present. When $encoding is omitted, it defaults to utf8 if $data is already in utf8 or "" (empty string) otherwise. encoder() is an alias of Encode::Encoder->new(). This one is exported on demand. $e->data([$data]) When $data is present, sets the instance data to $data and returns the object itself. Otherwise, the current instance data is returned. $e->encoding([$encoding]) When $encoding is present, sets the instance encoding to $encoding and returns the object itself. Otherwise, the current instance encoding is returned. $e->bytes([$encoding]) decodes instance data from $encoding, or the instance encoding if omitted. If the conversion is successful, the instance encoding will be set to "". The name bytes was deliberately picked to avoid namespace tainting -- this module may be used as a base class so method names that appear in Encode::Encoding are avoided. Example: base64 transcoder This module is designed to work with Encode::Encoding. To make the Base64 transcoder example above really work, you could write a module like this: package Encode::Base64; use base 'Encode::Encoding'; __PACKAGE__->Define('base64'); use MIME::Base64; sub encode{ my ($obj, $data) = @_; return encode_base64($data); } sub decode{ my ($obj, $data) = @_; return decode_base64($data); } 1; __END__ And your caller module would be something like this: use Encode::Encoder; use Encode::Base64; # now you can really do the following encoder($data)->iso_8859_1->base64; encoder($base64)->bytes('base64')->latin1; Operator Overloading This module overloads two operators, stringify ("") and numify (0+). Stringify dumps the data inside the object. Numify returns the number of bytes in the instance data. They come in handy when you want to print or find the size of data. SEE ALSO
Encode, Encode::Encoding perl v5.16.3 2013-04-29 Encode::Encoder(3)
Man Page