package Calendar::OO::HTML;

use warnings;
use strict;
use base 'Calendar::OO';
use CGI::Pretty;


=head1 NAME

Calendar::OO::HTML - The great new Calendar::OO::HTML!

=head1 VERSION

Version 0.01

=cut

our $VERSION = '0.01';

=head1 SYNOPSIS

Quick summary of what the module does.

Perhaps a little code snippet.

    use Calendar::OO::HTML;

    my $foo = Calendar::OO::HTML->new();
    ...

=head1 ATTRIBUTES

=cut

sub _defaults {
  return shift->SUPER::_defaults,
    (
     _cgi => CGI::Pretty->new(q()),
    );
}

sub _cgi { return shift->_scalar('_cgi', @_ ); }

=pod

=head1 METHODS

=cut

sub render_day {
  my ($self, $date) = @_;
  return $self->_cgi->td($date ? $date->day : q(&nbsp;));
}

sub render_week {
  my ($self, @days) = @_;
  return $self->_cgi->Tr(@days);
}

sub render_month {
  my ($self, @rows) = @_;
  
  return $self->_cgi->table(@rows);
}

sub month_row {
  my ($self) = @_;
  return $self->_cgi->Tr ($self->_cgi->th({-colspan => 7},$self->first->month_name,$self->first->year));
}

sub day_row {
  my ($self) = @_;
  return $self->_cgi->Tr($self->_cgi->th( [qw / Sun Mon Tue Wed Thu Fri Sat / ] ));
}

=head1 AUTHOR

Lawrence Statton, <lawrence at cluon.com>

=head1 BUGS

Please report any bugs or feature requests to
C<bug-html-calendar-oo at rt.cpan.org>, or through the web interface at
L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=HTML-Calendar-OO>.
I will be notified, and then you'll automatically be notified of progress on
your bug as I make changes.

=head1 SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc Calendar::OO::HTML

You can also look for information at:

=over 4

=item * AnnoCPAN: Annotated CPAN documentation

L<http://annocpan.org/dist/HTML-Calendar-OO>

=item * CPAN Ratings

L<http://cpanratings.perl.org/d/HTML-Calendar-OO>

=item * RT: CPAN's request tracker

L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=HTML-Calendar-OO>

=item * Search CPAN

L<http://search.cpan.org/dist/HTML-Calendar-OO>

=back

=head1 ACKNOWLEDGEMENTS

=head1 COPYRIGHT & LICENSE

Copyright 2007 Lawrence Statton, all rights reserved.

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

=cut

sub _scalar {
  my ($self, $attribute) = splice(@_,0,2);
  if (@_) {
    $self->{$attribute} = shift;
    return $self;
  } else {
    return $self->{$attribute};
  }
}


1; # End of Calendar::OO::HTML
