Quizzer::Base - Quizzer Base Class


Quizzer documentation Contained in the Quizzer distribution.

Index


Code Index:

NAME

Top

Quizzer::Base - Quizzer Base Class

DESCRIPTION

Top

Objects of this class may have any number of properties. These properties can be read by calling the method with the same name as the property. If a parameter is passed into the method, the property is set.

Properties can be made up and used on the fly; I don't care what you call them.

Something similar to this should be a generic perl object in the base perl distribution, since this is the most simple type of perl object. Until it is, I'll use this. (Sigh)

new

Returns a new object of this class.

any_other_method

Set/get a property.

AUTHOR

Top

Joey Hess <joey@kitenet.net>


Quizzer documentation Contained in the Quizzer distribution.
#!/usr/bin/perl -w

package Quizzer::Base;
use strict;
use vars qw($AUTOLOAD);

my $VERSION='0.01';

sub new {
	my $proto = shift;
	my $class = ref($proto) || $proto;
	my $self  = {};
	bless ($self, $class);
	return $self;
}

sub AUTOLOAD {
	my $this=shift;
	my $property = $AUTOLOAD;
	$property =~ s|.*:||; # strip fully-qualified portion
	
	$this->{$property}=shift if @_;
	return $this->{$property};
}

1