Created
September 22, 2011 01:15
-
-
Save smtalim/1233799 to your computer and use it in GitHub Desktop.
JRuby GradeService example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'grade_service' | |
service = GradeService.new 'http://grades.example.com' | |
answer = 'my answer to the assignment' | |
service.submit answer | |
puts "Status: #{service.status}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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