rpcoder¶ ↑ installation¶ ↑ $ gem install rpcoder generating AS3 RPC code¶ ↑ #!/usr/bin/env ruby require 'rpcoder' require 'fileutils' RPCoder.name_space = 'foo.bar.rpc' RPCoder.api_class_name = 'RPC' RPCoder.type "Mail" do |t| t.add_field :subject, :String t.add_field :body, :String end RPCoder.function "getMail" do |f| f.path = "/mails/:id" # => ("/mails/" + id) f.method = "GET" f.set_return_type "Mail" f.add_param :id, "int" f.description = 'メールを取得' end RPCoder.function "getMails" do |f| f.path = "/mails" f.method = "GET" f.set_return_type "Array", {:array_type => "Mail"} f.description = 'メールを送信' end RPCoder.function "sendMail" do |f| f.path = "/mails/create" f.method = "POST" f.set_return_type "void" f.add_param :subject, "String" f.add_param :body, "String" f.description = 'メールを送信' end # output codes dir = File.expand_path('src', File.dirname(__FILE__)) RPCoder.export(dir)