Module: WhirledPeas::Utils::FileHandler

Defined in:
lib/whirled_peas/utils/file_handler.rb

Class Method Summary collapse

Class Method Details

.read(file) ⇒ Object



53
54
55
56
57
58
59
# File 'lib/whirled_peas/utils/file_handler.rb', line 53

def self.read(file)
  Zlib::GzipReader.open(file) do |gz|
    version = gz.gets.chomp
    raise ArgumentError, "Invalid file: #{file}" unless READERS.key?(version)
    READERS[version].read(gz)
  end
end

.write(file, rendered_frames) ⇒ Object



46
47
48
49
50
51
# File 'lib/whirled_peas/utils/file_handler.rb', line 46

def self.write(file, rendered_frames)
  Zlib::GzipWriter.open(file, Zlib::BEST_COMPRESSION) do |gz|
    gz.puts FileWriter::VERSION
    FileWriter.write(gz, rendered_frames)
  end
end