[system] / branches / gage_dev / pg / lib / Fraction.pm Repository:
ViewVC logotype

Diff of /branches/gage_dev/pg/lib/Fraction.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 6330 Revision 6331
103 bless $self, $class; 103 bless $self, $class;
104 104
105 return $self; 105 return $self;
106} 106}
107 107
108sub AUTOLOAD { 108##########################
109# Access methods
110##########################
111sub numerator {
109 my $self = shift; 112 my $self = shift;
110
111 my $type = ref($self) or die "$self is not an object"; 113 my $type = ref($self) || die "$self is not an object";
112 114 unless (exists $self->{numerator} ) {
113 # $AUTOLOAD is sent in by Perl and is the full name of the object (i.e. main::blah::blah_more) 115 die "Can't find numerator field in object of class $type";
114 my $name = $Fraction::AUTOLOAD; 116 }
115 $name =~ s/.*://; #strips fully-qualified portion 117
116
117 unless ( exists $self->{'_permitted'}->{$name} ) { die "Can't find '$name' field in object of class '$type'";}
118
119 if (@_) { 118 if (@_) {
120 return $self->{$name} = shift; #set the variable to the first parameter 119 return $self->{numerator} = shift;
121 } else { 120 } else {
122 return $self->($name); #if no parameters just return the value 121 return $self->{numerator}
122 }
123}
124
125sub denominator {
126 my $self = shift;
127 my $type = ref($self) || die "$self is not an object";
128 unless (exists $self->{denominator} ) {
129 die "Can't find denominator field in object of class $type";
130 }
131
132 if (@_) {
133 return $self->{denominator} = shift;
134 } else {
135 return $self->{denominator}
123 } 136 }
124} 137}
125 138
126sub DESTROY { 139sub DESTROY {
127 # doing nothing about destruction, hope that isn't dangerous 140 # doing nothing about destruction, hope that isn't dangerous

Legend:
Removed from v.6330  
changed lines
  Added in v.6331

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9