-
-
Save ongaeshi/943877 to your computer and use it in GitHub Desktop.
tempfileへの書き込み関数
This file contains 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
require 'tempfile' | |
str = <<EOF | |
Lorem ipsum | |
Lorem ipsum dolor sit amet, | |
consectetur adipisicing elit, | |
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, | |
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. | |
EOF | |
def tempwrite(basename, str) | |
f = Tempfile.new(basename) | |
f.print str | |
f.close | |
return f | |
end | |
temp = tempwrite("temp", str) | |
GC.start | |
File.open(temp.path) do |f| | |
print f.read | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment