Skip to content

Instantly share code, notes, and snippets.

@nusco
Created August 18, 2010 15:07
Show Gist options
  • Save nusco/535051 to your computer and use it in GitHub Desktop.
Save nusco/535051 to your computer and use it in GitHub Desktop.
Spell: Code Processor
# =====================
# Spell: Code Processor
# =====================
# Process Strings of Code (http://gist.github.com/535047) from an external source.
File.readlines("file_containing_lines_of_ruby.txt").each do |line|
puts "#{line.chomp} ==> #{eval(line)}"
end
# >> 1 + 1 ==> 2
# >> 3 * 2 ==> 6
# >> Math.log10(100) ==> 2.0
# For more information: http://www.pragprog.com/titles/ppmetr/metaprogramming-ruby
1 + 1
3 * 2
Math.log10(100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment