Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ruby DATA and __END__ heredoc method
#!/usr/bin/ruby
DATA.each_line do |line|
puts line
end
__END__
Doom
Quake
Diablo
#!/usr/bin/ruby
require 'erb'
time = Time.now
renderer = ERB.new(DATA.read)
puts renderer.result()
__END__
The current time is <%= time %>.
#!/usr/bin/ruby
DATA.rewind
puts DATA.read # prints the entire source file
__END__
meh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment