Sha256: 5d59c113b2d8c5381748508a382c8c3b127f5c5ec1e3ef1ac8e6b6450c2d941f
Contents?: true
Size: 630 Bytes
Versions: 7
Compression:
Stored size: 630 Bytes
Contents
# frozen_string_literal: true module SimpleTextExtract class TempfileExtractor < TextExtractor attr_reader :filename, :raw def initialize(filename:, raw:) @filename = filename @raw = String.new(raw, encoding: Encoding::UTF_8) write_raw end private def file @file ||= Tempfile.new(filepath) end def write_raw file.write(raw) file.rewind end def cleanup file.close file.unlink end def filepath @filepath ||= filename.split(".").yield_self { |parts| [parts[0], ".#{parts[1]}"] } end end end
Version data entries
7 entries across 7 versions & 1 rubygems