/[Frey]/branches/zimbardo/lib/App/RoomReservation/Room.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /branches/zimbardo/lib/App/RoomReservation/Room.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1086 - (hide annotations)
Sun Jun 28 14:21:10 2009 UTC (14 years, 10 months ago) by dpavlin
Original Path: trunk/lib/App/RoomReservation/Room.pm
File size: 965 byte(s)
Simple object schema for room reservation example application
1 dpavlin 1086 package App::RoomReservation::Room;
2     use Moose::Role;
3    
4     has room => (
5     is => 'rw',
6     isa => 'Str',
7     required => 1,
8     default => 'zimbardo',
9     );
10    
11     has description => (
12     is => 'rw',
13     isa => 'Str',
14     required => 1,
15     default => q|
16     <h2>Prijava za predavanje profesora Phillipa Zimbarda "The Lucifer Effect"</h2>
17     <h3>28. 9. 2009. u 12 sati </h3>
18     |,
19     );
20    
21     has seats => (
22     is => 'rw',
23     isa => 'Int',
24     required => 1,
25     default => 600,
26     );
27    
28     sub seats_full { 42 }
29    
30     sub seats_left {
31     my ($self) = @_;
32     $self->seats - $self->seats_full;
33     }
34    
35     sub room_markup {
36     my ($self) = @_;
37    
38     my $size = 50; # %
39    
40     my $full = int( $size * ( $self->seats_full / $self->seats ) );
41     my $left = int( $size * ( $self->seats_left / $self->seats ) );
42    
43     $self->description
44     . qq|
45     <table width=$size%>
46     <tr><th colspan=2>seats</th></tr>
47     <tr><th>full</th><th>left</th>
48     <tr><td width=$full%>
49     | . $self->seats_full . qq|
50     </td><td width=$left%>
51     | . $self->seats_left . qq|
52     </td></tr>
53     </table>
54     |
55     }
56    
57     1;

  ViewVC Help
Powered by ViewVC 1.1.26