Created
July 25, 2016 14:56
-
-
Save tuxfight3r/f4e98228e0c5b8be7901caeef8cc2c66 to your computer and use it in GitHub Desktop.
ruby DATA and __END__ heredoc method
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
DATA.each_line do |line| | |
puts line | |
end | |
__END__ | |
Doom | |
Quake | |
Diablo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require 'erb' | |
time = Time.now | |
renderer = ERB.new(DATA.read) | |
puts renderer.result() | |
__END__ | |
The current time is <%= time %>. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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