11package com .purbon ;
22
3- import org .jruby .Ruby ;
4- import org .jruby .RubyClass ;
5- import org .jruby .RubyObject ;
6- import org .jruby .RubyString ;
3+ import org .jruby .*;
74import org .jruby .anno .JRubyClass ;
85import org .jruby .anno .JRubyMethod ;
96import org .jruby .runtime .ThreadContext ;
@@ -26,4 +23,24 @@ public static RubyString shout(ThreadContext context, IRubyObject self) {
2623 return context .runtime .newString ("Hello World!" );
2724 }
2825
26+ @ JRubyMethod (module = true , name = "add" )
27+ public IRubyObject add (ThreadContext context , IRubyObject a , IRubyObject b ) {
28+ return a .callMethod (context , "+" , b );
29+ }
30+
31+ @ JRubyMethod (module = true , name = "sub" )
32+ public IRubyObject sub (ThreadContext context , IRubyObject a , IRubyObject b ) {
33+ return a .callMethod (context , "-" , b );
34+ }
35+
36+ @ JRubyMethod (module = true , name = "div" )
37+ public IRubyObject div (ThreadContext context , IRubyObject a , IRubyObject b ) {
38+ return a .callMethod (context , "/" , b );
39+ }
40+
41+ @ JRubyMethod (module = true , name = "plus" )
42+ public IRubyObject plus (ThreadContext context , IRubyObject a , IRubyObject b ) {
43+ return a .callMethod (context , "*" , b );
44+ }
45+
2946}
0 commit comments