Skip to content

Instantly share code, notes, and snippets.

@badosu
Created August 3, 2016 17:12
Show Gist options
  • Save badosu/d60dcb9fa18bae98b6071f468606ab41 to your computer and use it in GitHub Desktop.
Save badosu/d60dcb9fa18bae98b6071f468606ab41 to your computer and use it in GitHub Desktop.
def get_binding
a = 1
@c = 3
@d = 4
e5 = 5
a8 = 8
binding
end
temp = "<%= :sym %>,<%= 'str' %>,<%= 1.1 %>,<%= ['a', 2, a8].map {|a| a.to_s }.join %>,<%= ['a', 2, a8].map(&:to_s).join %>\n<%= a %><% b = 2 %><%= b %><% c = @c %><%= c %><%= @d %><% e = e5 %><%= e %><%= 6.to_s %><%= 3 + 4 %><%= a8.to_i %>"
frb = FRB.new(temp)
puts frb.result(get_binding)
require 'erb'
puts ERB.new(temp).src
#coding:UTF-8
_erbout = String.new; _erbout.concat((:sym).to_s); _erbout.concat ","; _erbout.concat(('str').to_s); _erbout.concat ","; _erbout.concat((1.1).to_s); _erbout.concat ","; _erbout.concat((((['a',2,_b.local_variable_defined?(:a8) ? _b.local_variable_get(:a8) : _b.a8]).map {|a| (a).to_s}).join).to_s); _erbout.concat ","; _erbout.concat((_b.eval(%q(['a', 2, a8].map(&:to_s).join))).to_s); _erbout.concat "\n"
; _erbout.concat((_b.local_variable_defined?(:a) ? _b.local_variable_get(:a) : _b.a).to_s); _b.local_variable_set(:b, 2); _erbout.concat((_b.local_variable_defined?(:b) ? _b.local_variable_get(:b) : _b.b).to_s); _b.local_variable_set(:c, _b.eval(%q(@c))); _erbout.concat((_b.local_variable_defined?(:c) ? _b.local_variable_get(:c) : _b.c).to_s); _erbout.concat((_b.eval(%q(@d))).to_s); _b.local_variable_set(:e, _b.local_variable_defined?(:e5) ? _b.local_variable_get(:e5) : _b.e5); _erbout.concat((_b.local_variable_defined?(:e) ? _b.local_variable_get(:e) : _b.e).to_s); _erbout.concat(((6).to_s).to_s); _erbout.concat((_b.eval(%q(3 + 4))).to_s); _erbout.concat(((_b.local_variable_defined?(:a8) ? _b.local_variable_get(:a8) : _b.a8).to_i).to_s); _erbout.force_encoding(__ENCODING__)
#coding:UTF-8
_erbout = ''; _erbout.concat(( :sym ).to_s); _erbout.concat ","; _erbout.concat(( 'str' ).to_s); _erbout.concat ","; _erbout.concat(( 1.1 ).to_s); _erbout.concat ","; _erbout.concat(( ['a', 2, a8].map {|a| a.to_s }.join ).to_s); _erbout.concat ","; _erbout.concat(( ['a', 2, a8].map(&:to_s).join ).to_s); _erbout.concat "\n"
; _erbout.concat(( a ).to_s); b = 2 ; _erbout.concat(( b ).to_s); c = @c ; _erbout.concat(( c ).to_s); _erbout.concat(( @d ).to_s); e = e5 ; _erbout.concat(( e ).to_s); _erbout.concat(( 6.to_s ).to_s); _erbout.concat(( 3 + 4 ).to_s); _erbout.concat(( a8.to_i ).to_s); _erbout.force_encoding(__ENCODING__)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment