forked from jruby/jruby
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCompatVersion.java
More file actions
39 lines (33 loc) · 1.41 KB
/
Copy pathCompatVersion.java
File metadata and controls
39 lines (33 loc) · 1.41 KB
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
32
33
34
35
36
37
38
39
package org.jruby;
public enum CompatVersion {
RUBY1_8, RUBY1_9, RUBY2_0, BOTH;
public boolean is1_9() {
return this == RUBY1_9 || this == RUBY2_0;
}
public boolean is2_0() {
return this == RUBY2_0;
}
public static CompatVersion getVersionFromString(String compatString) {
if (compatString.equalsIgnoreCase("RUBY1_8")) {
return CompatVersion.RUBY1_8;
} else if (compatString.equalsIgnoreCase("1.8")) {
return CompatVersion.RUBY1_8;
} else if (compatString.equalsIgnoreCase("RUBY1_9")) {
return CompatVersion.RUBY1_9;
} else if (compatString.equalsIgnoreCase("1.9")) {
return CompatVersion.RUBY1_9;
} else if (compatString.equalsIgnoreCase("RUBY2_0")) {
return CompatVersion.RUBY2_0;
} else if (compatString.equalsIgnoreCase("2.0")) {
return CompatVersion.RUBY2_0;
} else {
return null;
}
}
public static boolean shouldBindMethod(CompatVersion runtimeVersion, CompatVersion methodVersion) {
if (runtimeVersion == RUBY1_8) return methodVersion == RUBY1_8 || methodVersion == BOTH;
if (runtimeVersion == RUBY1_9) return methodVersion == RUBY1_9 || methodVersion == BOTH;
if (runtimeVersion == RUBY2_0) return methodVersion == RUBY1_9 || methodVersion == RUBY2_0 || methodVersion == BOTH;
return false;
}
}