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
32
32
# interpolate in a string
33
33
my $stringyval = "version: $version";
34
34
35
+ # get the major version
36
+ my $maj = $version->major;
37
+
35
38
=head1 DESCRIPTION
36
39
37
40
PostgresVersion encapsulates Postgres version numbers, providing parsing
@@ -133,4 +136,29 @@ sub _stringify
133
136
return $self -> {str };
134
137
}
135
138
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
+
136
164
1;
You can’t perform that action at this time.
0 commit comments