Skip to content

Instantly share code, notes, and snippets.

@fcheung
Created June 2, 2015 21:09
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 fcheung/1d525c097e6e520bc039 to your computer and use it in GitHub Desktop.
Save fcheung/1d525c097e6e520bc039 to your computer and use it in GitHub Desktop.
binding from inside c method
gem 'RubyInline'
require 'inline'
class Test
inline do |builder|
builder.include "<time.h>"
builder.c_raw <<-SRC, :arity => 1
VALUE dummy(VALUE self, VALUE arg){
VALUE ret = rb_funcall(self, rb_intern("binding"), 0);
return ret;
}
SRC
end
end
binding_from_method = Test.new.dummy(123)
puts binding_from_method.local_variables.inspect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment