File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,9 @@ PostgresVersion - class representing PostgreSQL version numbers
3232 # interpolate in a string
3333 my $stringyval = "version: $version";
3434
35+ # get the major version
36+ my $maj = $version->major;
37+
3538=head1 DESCRIPTION
3639
3740PostgresVersion encapsulates Postgres version numbers, providing parsing
@@ -133,4 +136,29 @@ sub _stringify
133136 return $self -> {str };
134137}
135138
139+ =pod
140+
141+ =over
142+
143+ =item major([separator => 'char'])
144+
145+ Returns the major version. For versions before 10 the parts are separated by
146+ a dot unless the separator argument is given.
147+
148+ =back
149+
150+ =cut
151+
152+ sub major
153+ {
154+ my ($self , %params ) = @_ ;
155+ my $result = $self -> {num }-> [0];
156+ if ($result + 0 < 10)
157+ {
158+ my $sep = $params {separator } || ' .' ;
159+ $result .= " $sep$self ->{num}->[1]" ;
160+ }
161+ return $result ;
162+ }
163+
1361641;
You can’t perform that action at this time.
0 commit comments