Report abuse

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
    /**
     * JRuby version, assumes the version to be of format major.minor.suffix
     */
    private static class JRubyVersion {

        private final int major, minor, suffix;

        public JRubyVersion() {
            this(org.jruby.runtime.Constants.VERSION);
        }

        private JRubyVersion(String version) {
            int i = version.lastIndexOf('.');
            if (i != -1) {
                suffix = Integer.parseInt(version.substring(i + 1, version.length()));
                int j = version.substring(0, i).lastIndexOf('.');
                if (j != -1) {
                    minor = Integer.parseInt(version.substring(j + 1, i));
                    if (j != 0)
                        major = Integer.parseInt(version.substring(0, j));
                    else
                        major = 0;

                } else {
                    minor = 0;
                    major = 1;
                }
            } else {
                major = minor = suffix = 0;
            }
        }