Skip to content

Instantly share code, notes, and snippets.

@tuxfight3r
Created July 25, 2016 14:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tuxfight3r/f4e98228e0c5b8be7901caeef8cc2c66 to your computer and use it in GitHub Desktop.
Save tuxfight3r/f4e98228e0c5b8be7901caeef8cc2c66 to your computer and use it in GitHub Desktop.
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