Permalink
Browse files

Yup.

  • Loading branch information...
0 parents commit c51564a4c54fbee05e29f3667e7242ebb9536396 @headius committed Sep 27, 2011
Showing with 44 additions and 0 deletions.
  1. +23 −0 Simple.java
  2. +21 −0 using_simple.rb
@@ -0,0 +1,23 @@
+public class Simple {
+ private String name;
+ public int number;
+
+ public Simple(String name, int number) {
+ this.name = name;
+ this.number = number;
+ }
+
+ public String getName() { return name; }
+ public int getNumber() { return number; }
+ public void setName(String name) {
+ this.name = name;
+ }
+ public void setNumber(int number) {
+ this.number = number;
+ }
+
+ public void doSomething(Runnable something) {
+ System.out.println("something in " + name + "#" + number);
+ something.run();
+ }
+}
@@ -0,0 +1,21 @@
+require 'java'
+# jar files can be required...no CLASSPATH needed
+# require 'foo.jar'
+
+# for java/javax/com/org, package name works
+# java_import java.util.ArrayList
+java_import Java::Simple
+
+# constructor call
+simple = Simple.new('RubyConf', 2010)
+# same as getName or get_name
+simple.name
+# setName or set_name
+simple.name = "JRubyConf"
+# access public field
+simple.number
+# call method with interface as last argument
+simple.do_something {
+ # body becomes Runnable impl
+ puts "hello!"
+}

0 comments on commit c51564a

Please sign in to comment.