Class: Recursivar::TmpFile
Instance Method Summary collapse
-
#initialize(obj) ⇒ TmpFile
constructor
A new instance of TmpFile.
- #puts(*content) ⇒ Object
Constructor Details
#initialize(obj) ⇒ TmpFile
Returns a new instance of TmpFile.
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/recursivar/tmp_file.rb', line 4 def initialize(obj) name = [ Time.now.strftime('%Y%m%d_%H%M%S_%L_'), obj.class.to_s.split('::').map(&:downcase).join('_'), '_', obj.object_id, '.html', ].join @path = File.join(Dir.tmpdir, name) end |
Instance Method Details
#puts(*content) ⇒ Object
16 17 18 19 20 |
# File 'lib/recursivar/tmp_file.rb', line 16 def puts(*content) File.open @path, 'a' do |f| f.puts *content end end |