Skip to content

Instantly share code, notes, and snippets.

@tomoyamkung
Created July 29, 2013 04:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomoyamkung/6102119 to your computer and use it in GitHub Desktop.
Save tomoyamkung/6102119 to your computer and use it in GitHub Desktop.
[Ruby]Arrayを Tempfile に書き出すモジュール
#! 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