hellojava 0.0.3-java → 0.0.4-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1cffd381d1e1109af675b8cb94187962e67b6dbf3ea6042eb97b5a9f073eb3ec
4
- data.tar.gz: 46b0dd75a091b2102b8749a13b9875d9cc6ca0dbb5de8e8a29c14d9c983bff75
3
+ metadata.gz: 85d5257583e5e4c9fe0f8cfdc6670731efc2c60a615f69c4f4aebb6cec3d072a
4
+ data.tar.gz: f52eaef3c17a67b13a7ba569f11a94ab06947073b22f82e753e2127bf653ad41
5
5
  SHA512:
6
- metadata.gz: 38a4c1b06b61727bd80a75ef5304acbc07f3fd97f3cfd3ab18172e8d7386fe56d44e919dd0b02e25eac5525a600bf0f4ee39db60fbb406b0f72b55798c0edd63
7
- data.tar.gz: 564535daf02d2b576adcd9a7af2baa000d0226b2ac1368bc2676a799bb8e07271e1a047c7d5e53c87d0cca1ff7dc0f12a9cebaa1ee4a22378d7dbe34f96abb22
6
+ metadata.gz: 7c7e85c556980fbdae896014869b9dd7e2cbe811ab2912fc40fd555c85d39e3a6b2063378df5ba4d798adc87948f4a40fc8220aa711c64784f5a263c802ef010
7
+ data.tar.gz: d6fc7296259986a9bb8e32205cdf1dcfc28b3160decb7da3ed1ffc10213a2c34e49bd8ba1d945f20fb6174b0d2ceafee53c29575547a486421a00953d4471164
data/CHANGELOG.md CHANGED
@@ -2,10 +2,15 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## [0.0.4] - 2023-11-03
6
+
7
+ ### Added
8
+ - Add parameter test of function type.
9
+
5
10
  ## [0.0.3] - 2023-10-21
6
11
 
7
12
  ### Added
8
- - Add test parameter of A two-dimensional array
13
+ - Add parameter test of A two-dimensional array.
9
14
 
10
15
  ## [0.0.2] - 2023-09-27
11
16
 
@@ -0,0 +1,20 @@
1
+ import java.util.function.Function;
2
+ import java.util.function.Consumer;
3
+ import java.util.function.Predicate;
4
+ import java.util.function.Supplier;
5
+
6
+ public class JavaCallTest2 {
7
+ public static void funcType1(String str, Consumer<String> func) {
8
+ System.out.println("funcType1 in");
9
+ func.accept(str);
10
+ }
11
+ public static String funcType2(Supplier<String> func) {
12
+ System.out.println("funcType2 in");
13
+ return func.get();
14
+ }
15
+ public static double funcType3(double[] vals, Function<double[], Double> func) {
16
+ System.out.println("funcType3 in");
17
+ return func.apply(vals);
18
+ }
19
+ }
20
+
data/lib/hellojava.rb CHANGED
@@ -2,8 +2,10 @@ require 'java'
2
2
  require 'hellojava.jar'
3
3
  java_import 'java.lang.System'
4
4
  java_import 'JavaCallTest'
5
+ java_import 'JavaCallTest2'
5
6
  java_import 'Hoge'
6
7
 
8
+ # jrubyからjavaの呼び出し
7
9
  module HelloJavaLib
8
10
  # Systemクラス使用
9
11
  #
@@ -57,11 +59,63 @@ module HelloJavaLib
57
59
  # vals[1] size:5
58
60
  # 12.300000 22.500000 33.700000 44.600000 55.800000
59
61
  def func_d(fname, vals)
60
- p JavaCallTest.sub1(
62
+ JavaCallTest.sub1(
61
63
  fname, vals.to_java(Java::double[])
62
64
  );
63
65
  return
64
66
  end
67
+ # 引数に関数型の場合
68
+ class FuncTypes
69
+ class << self
70
+ # @overload func_type1(str, &func)
71
+ # @param [String] str 文字列
72
+ # @param [block] func 関数型(引数:文字列, 戻り値:なし)
73
+ # @return [void]
74
+ # @example
75
+ # HelloJavaLib::FuncTypes.func_type1("Hello") {|s|
76
+ # p s + "!!"
77
+ # next
78
+ # }
79
+ # =>
80
+ # funcType1 in
81
+ # "Hello!!"
82
+ def func_type1(str, &func)
83
+ JavaCallTest2.funcType1(str, func)
84
+ return
85
+ end
86
+ # @overload func_type2(&func)
87
+ # @param [block] func 関数型(引数:なし, 戻り値:文字列)
88
+ # @return [void]
89
+ # @example
90
+ # HelloJavaLib::FuncTypes.func_type2() {
91
+ # next "Hello"
92
+ # }
93
+ # =>
94
+ # funcType2 in
95
+ # "Hello"
96
+ def func_type2(&func)
97
+ p JavaCallTest2.funcType2(func)
98
+ return
99
+ end
100
+ # @overload func_type3(vals, &func)
101
+ # @param [Array] vals double型の配列(duble[])
102
+ # @param [block] func 関数型(引数:double[], 戻り値:double)
103
+ # @return [void]
104
+ # @example
105
+ # vals = [11, 22, 33, 44]
106
+ # HelloJavaLib::FuncTypes.func_type3(vals) {|xi|
107
+ # next xi.sum(0.0) / xi.length
108
+ # }
109
+ # =>
110
+ # funcType3 in
111
+ # 27.5
112
+ def func_type3(vals, &func)
113
+ p JavaCallTest2.funcType3(vals.to_java(Java::double), func)
114
+ return
115
+ end
116
+
117
+ end
118
+ end
65
119
  module_function :func_a
66
120
  module_function :func_b
67
121
  module_function :func_c
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.3
4
+ version: 0.0.4
5
5
  platform: java
6
6
  authors:
7
7
  - siranovel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-21 00:00:00.000000000 Z
11
+ date: 2023-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -64,6 +64,7 @@ files:
64
64
  - ext/hellojava/Calc.java
65
65
  - ext/hellojava/Hoge.java
66
66
  - ext/hellojava/JavaCallTest.java
67
+ - ext/hellojava/JavaCallTest2.java
67
68
  - lib/hellojava.rb
68
69
  homepage: http://github.com/siranovel/stdy4act
69
70
  licenses: