benolee / yarv_dsl.rb secret
Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

using RubyVM::InstructionSequence.disassemble for a DSL

View yarv_dsl.rb
1 2 3 4 5 6 7
def wat &block
method, receiver, *args = RubyVM::InstructionSequence.disassemble(block).scan(/send\s+:(\w+)/).reverse.flatten
{ receiver: receiver, method: method, args: args }
end
 
wat { (puts Kernel test (hello world)) }
#=> {:receiver=>"Kernel", :method=>"puts", :args=>["test", "hello", "world"]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.