Created
July 29, 2013 04:17
-
-
Save tomoyamkung/6102119 to your computer and use it in GitHub Desktop.
[Ruby]Arrayを 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
#! ruby | |
#-*- encoding: utf-8 -*- | |
module ArrayToTempfile | |
require 'tempfile' | |
def write_array_to_tempfile(basename, array) | |
@tempfile = Tempfile.new(basename) | |
array.each do |line| | |
@tempfile.puts(line) | |
end | |
@tempfile.close | |
end | |
def get_tempfile_path | |
return @tempfile.path | |
end | |
def delete_tempfile | |
@tempfile.unlink | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment