Module: CRFPP::Filelike
Instance Attribute Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#path ⇒ Object
7 8 9 |
# File 'lib/crfpp/filelike.rb', line 7 def path @path ||= Tempfile.new('filelike').path end |
Instance Method Details
#read ⇒ Object
18 19 20 21 22 23 |
# File 'lib/crfpp/filelike.rb', line 18 def read f = File.open(path, 'r:UTF-8') f.read ensure f.close end |
#write ⇒ Object
11 12 13 14 15 16 |
# File 'lib/crfpp/filelike.rb', line 11 def write File.open(path, 'w:UTF-8') do |f| f.write(to_s) f.close end end |