Skip to content

Instantly share code, notes, and snippets.

@smtalim
Created September 22, 2011 01:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smtalim/1233799 to your computer and use it in GitHub Desktop.
Save smtalim/1233799 to your computer and use it in GitHub Desktop.
JRuby GradeService example
class GradeService
def initialize(url)
@url = url
end
def submit(answer)
# do web request here
end
def status
# do web request here
'passed'
end
end
require 'grade_service'
service = GradeService.new 'http://grades.example.com'
answer = 'my answer to the assignment'
service.submit answer
puts "Status: #{service.status}"
$ javap grade_service
Compiled from "grade_service.rb"
public class grade_service extends org.jruby.ast.executable.AbstractScript{
public grade_service();
public static org.jruby.runtime.builtin.IRubyObject class_0$RUBY
$GradeService(grade_service, org.jruby.runtime.ThreadContext,
org.jruby.runtime.builtin.IRubyObject, org.jruby.runtime.Block);
public static org.jruby.runtime.builtin.IRubyObject
method__2$RUBY$submit(grade_service, org.jruby.runtime.ThreadContext,
org.jruby.runtime.builtin.IRubyObject,
org.jruby.runtime.builtin.IRubyObject[], org.jruby.runtime.Block);
public static org.jruby.runtime.builtin.IRubyObject
method__3$RUBY$status(grade_service, org.jruby.runtime.ThreadContext,
org.jruby.runtime.builtin.IRubyObject,
org.jruby.runtime.builtin.IRubyObject[], org.jruby.runtime.Block);
// lots of other stuff...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment