Skip to content

Instantly share code, notes, and snippets.

@fcheung
Created Jun 2, 2015
Embed
What would you like to do?
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