Module: CRFPP::Filelike

Included in:
Model, Template
Defined in:
lib/crfpp/filelike.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#pathObject



7
8
9
# File 'lib/crfpp/filelike.rb', line 7

def path
  @path ||= Tempfile.new('filelike').path
end

Instance Method Details

#readObject



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

#writeObject



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