hellojava 0.0.4-java → 0.0.5-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/ext/hellojava/JavaCallTest.java +13 -1
- data/lib/hellojava.rb +28 -5
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd8720bbd199d2a6550935f31fcb287c4a34c56989c37423e21b75e0a2c105fc
|
4
|
+
data.tar.gz: c7d9b01cfc2c859b8b22d2ee96d1a0aa4104bec9426d12c9d771aa9cb995235b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97a9371b1ea24d09271d19ea2e3a3d89c170a997370ef1c0e52dbcb653f0b316113b1b9e6990f318871f99be6d83f4a9e4fb16fe31980117a412f7383b3dc440
|
7
|
+
data.tar.gz: d51e36fb15912e52fa54d3859b1e826f9470833eec0b422a887c8f49ef262451ddbed1d86ccd7725ccb66cb389607c55eb410068ca04d3d5c081f5e1c6bf3487
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
import java.util.ArrayList;
|
2
|
+
import java.util.Map;
|
2
3
|
|
3
4
|
public class JavaCallTest {
|
4
5
|
public static String str1() {
|
@@ -16,6 +17,17 @@ public class JavaCallTest {
|
|
16
17
|
}
|
17
18
|
System.out.println();
|
18
19
|
}
|
19
|
-
}
|
20
|
+
}
|
21
|
+
public static void hash(Map<String, double[]> vals) {
|
22
|
+
System.out.println("hash in");
|
23
|
+
for(Map.Entry<String, double[]> entry : vals.entrySet()) {
|
24
|
+
System.out.print(entry.getKey());
|
25
|
+
double[] v = entry.getValue();
|
26
|
+
for(int i = 0; i < v.length; i++) {
|
27
|
+
System.out.printf(" %f", v[i]);
|
28
|
+
}
|
29
|
+
System.out.println();
|
30
|
+
}
|
31
|
+
}
|
20
32
|
}
|
21
33
|
|
data/lib/hellojava.rb
CHANGED
@@ -4,6 +4,7 @@ java_import 'java.lang.System'
|
|
4
4
|
java_import 'JavaCallTest'
|
5
5
|
java_import 'JavaCallTest2'
|
6
6
|
java_import 'Hoge'
|
7
|
+
java_import 'java.util.HashMap'
|
7
8
|
|
8
9
|
# jrubyからjavaの呼び出し
|
9
10
|
module HelloJavaLib
|
@@ -42,7 +43,7 @@ module HelloJavaLib
|
|
42
43
|
end
|
43
44
|
# 引数に二次元配列の場合
|
44
45
|
#
|
45
|
-
# @overload
|
46
|
+
# @overload func_v(fname, vals)
|
46
47
|
# @param [String] fname 文字列
|
47
48
|
# @param [Array] vals 二次元の配列(double[][])
|
48
49
|
# @return [void]
|
@@ -51,19 +52,41 @@ module HelloJavaLib
|
|
51
52
|
# [12.3, 22.5, 33.7, 44.6],
|
52
53
|
# [12.3, 22.5, 33.7, 44.6, 55.8],
|
53
54
|
# ]
|
54
|
-
# HelloJavaLib::
|
55
|
+
# HelloJavaLib::func_v("fname.jpg", vals)
|
55
56
|
# =>
|
56
57
|
# fname:fname.jpg size:2
|
57
58
|
# vals[0] size:4
|
58
59
|
# 12.300000 22.500000 33.700000 44.600000
|
59
60
|
# vals[1] size:5
|
60
61
|
# 12.300000 22.500000 33.700000 44.600000 55.800000
|
61
|
-
def
|
62
|
+
def func_v(fname, vals)
|
62
63
|
JavaCallTest.sub1(
|
63
64
|
fname, vals.to_java(Java::double[])
|
64
65
|
);
|
65
66
|
return
|
66
67
|
end
|
68
|
+
# 引数にHashの場合
|
69
|
+
#
|
70
|
+
# @overload func_h(vals)
|
71
|
+
# @param [Hash] vals Hash(String, double[])
|
72
|
+
# @return [void]
|
73
|
+
# @example
|
74
|
+
# vals = {
|
75
|
+
# "dt1" => [12.3, 22.5, 33.7, 44.6],
|
76
|
+
# "dt2" => [12.3, 22.5, 33.7, 44.6, 55.8],
|
77
|
+
# }
|
78
|
+
# HelloJavaLib::func_h(vals)
|
79
|
+
# =>
|
80
|
+
# hash in
|
81
|
+
# dt1 12.300000 22.500000 33.700000 44.600000
|
82
|
+
# dt2 12.300000 22.500000 33.700000 44.600000 55.800000
|
83
|
+
def func_h(vals)
|
84
|
+
o = HashMap.new
|
85
|
+
vals.each{|k, v|
|
86
|
+
o[k] = v.to_java(Java::double)
|
87
|
+
}
|
88
|
+
JavaCallTest.hash(o)
|
89
|
+
end
|
67
90
|
# 引数に関数型の場合
|
68
91
|
class FuncTypes
|
69
92
|
class << self
|
@@ -119,7 +142,7 @@ module HelloJavaLib
|
|
119
142
|
module_function :func_a
|
120
143
|
module_function :func_b
|
121
144
|
module_function :func_c
|
122
|
-
module_function :
|
123
|
-
|
145
|
+
module_function :func_v
|
146
|
+
module_function :func_h
|
124
147
|
end
|
125
148
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hellojava
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- siranovel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-12-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -20,8 +20,8 @@ dependencies:
|
|
20
20
|
- !ruby/object:Gem::Version
|
21
21
|
version: 12.3.3
|
22
22
|
name: rake
|
23
|
-
prerelease: false
|
24
23
|
type: :development
|
24
|
+
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - "~>"
|
@@ -40,8 +40,8 @@ dependencies:
|
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: 1.2.5
|
42
42
|
name: rake-compiler
|
43
|
-
prerelease: false
|
44
43
|
type: :development
|
44
|
+
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
47
|
- - "~>"
|