Skip to content

Instantly share code, notes, and snippets.

/ruby.rb Secret

Created August 18, 2017 10:40
Show Gist options
  • Save anonymous/714752bfb3744ba80f556d10f06f8c04 to your computer and use it in GitHub Desktop.
Save anonymous/714752bfb3744ba80f556d10f06f8c04 to your computer and use it in GitHub Desktop.
Output:
RUBY
====
"server"
"host"
["a", "b"]
{:licence=>"lic"}
NATIVE
======
"server"
"host"
["a", "b", {:licence=>"lic"}]
false
$ cat ../../test.rb
puts "RUBY"
puts "===="
def loc_test server, host, *others, **hash
p server
p host
p others
p hash
end
loc_test "server", "host", "a", "b", licence: "lic"
puts
puts "NATIVE"
puts "======"
Test.test "server", "host", "a", "b", licence: "lic"
$ cat poskit_server.c
#include <ruby.h>
VALUE module = Qnil;
VALUE method_test(int argc, VALUE * argv, VALUE self);
void Init_poskit_server(void) {
module = rb_define_module("Test");
rb_define_singleton_method(module, "test", method_test, -1);
}
VALUE method_test(int argc, VALUE * argv, VALUE self) {
VALUE name, host, others, hash;
rb_scan_args(argc, argv, "11*:", &name, &host, &others, &hash);
rb_p(name);
rb_p(host);
rb_p(others);
rb_p(hash);
return INT2NUM(10);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment