Class: TraceTree::TmpFile

Inherits:
Object
  • Object
show all
Defined in:
lib/trace_tree/tmp_file.rb

Constant Summary collapse

DefaultName =
'trace_tree.html'

Instance Method Summary collapse

Constructor Details

#initialize(path, transcode: false) ⇒ TmpFile

Returns a new instance of TmpFile.



15
16
17
18
19
# File 'lib/trace_tree/tmp_file.rb', line 15

def initialize path, transcode: false
  path = recognize_dir path
  @tmp = custom path
  @transcode = transcode
end

Instance Method Details

#pathObject



29
30
31
# File 'lib/trace_tree/tmp_file.rb', line 29

def path
  @tmp
end

#puts(*content) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/trace_tree/tmp_file.rb', line 21

def puts *content
  content = content.map{ |c| c.to_s.encode('UTF-8', invalid: :replace, undef: :replace, replace: '?') } if @transcode

  File.open @tmp, 'a' do |f|
    f.puts(*content)
  end
end