E2::Room - A module for loading rooms on L<http://everything2.com>.


E2-Interface documentation Contained in the E2-Interface distribution.

Index


Code Index:

NAME

Top

E2::Room - A module for loading rooms on http://everything2.com.

SYNOPSIS

Top

	use E2::Room;

	my $room = new E2::Room;

	$room->login( "username", "password" ); # See E2::Interface

	if( $room->load( "test" ) ) {                       # See E2::Node
		print 'Room name: ' . $room->title;         # See E2::Node
		print '\nDescription: . $group->description;
		print '\nYou ' . 
			($room->can_enter ? "can" : "can't") .
			"enter.\n";
	}

DESCRIPTION

Top

This module provides access to http://everything2.com's rooms. It inherits E2::Node.

CONSTRUCTOR

Top

new

new creates a new E2::Room object. Until that object is logged in in one way or another (see E2::Interface), it will use the "Guest User" account.

METHODS

Top

$room->clear

clear clears all the information currently stored in $room.

$room->description

This method returns the description string of the currently-loaded room. It returns undef if no usergroup is loaded.

$room->can_enter

This method returns a boolean value: whether or not the currently-logged-in user can enter this room.

SEE ALSO

Top

E2::Interface, E2::Node, http://everything2.com, http://everything2.com/?node=clientdev

AUTHOR

Top

Jose M. Weeks <jose@joseweeks.com> (Simpleton on E2)

COPYRIGHT

Top


E2-Interface documentation Contained in the E2-Interface distribution.

# E2::Room.pm
# Jose M. Weeks <jose@joseweeks.com>
# 05 June 2003
#
# See bottom for pod documentation.

package E2::Room;

use 5.006;
use strict;
use warnings;
use Carp;

use E2::Node;

our @ISA = "E2::Node";
our $VERSION = "0.32";
our $DEBUG; *DEBUG = *E2::Interface::DEBUG;

# Prototypes

sub new;
sub clear;

sub description;
sub can_enter;

# Private

sub type_as_string;
sub twig_handlers;

# Object Methods

sub new {
	my $arg   = shift;
	my $class = ref( $arg ) || $arg;
	my $self  = $class->SUPER::new();

	# See clear for the other members of $self

	$self->clear;
	return $self;
}

sub clear {
	my $self = shift	or croak "Usage: clear E2USERGROUP";

	warn "E2::Room::clear\n"	if $DEBUG > 1;

	$self->{description}	= undef;
	$self->{can_enter}	= undef;

	# Now clear parent

	return $self->SUPER::clear;
}

sub twig_handlers {
	my $self = shift or croak "Usage: twig_handlers E2USERGROUP";

	return (
		'description' => sub {
			(my $a, my $b) = @_;
			$self->{description} = $b->text;
		},
		'canenter' => sub {
			(my $a, my $b) = @_;
			$self->{can_enter} = $b->text;
		}
	);
}			

sub type_as_string {
	return 'room';
}

sub description {
	my $self = shift	or croak "Usage: description E2ROOM";
	return $self->{description};
}

sub can_enter {
	my $self = shift	or croak "Usage: can_enter E2ROOM";
	return $self->{can_enter};
}

1;
__END__