Class: Avm::FileFormats::Utf8Assert

Inherits:
Object
  • Object
show all
Defined in:
lib/avm/file_formats/utf8_assert.rb

Constant Summary collapse

UTF8_CHARSET =
'utf-8'
UTF8_CHARSETS =
[UTF8_CHARSET, 'us-ascii'].freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.assert_files(files) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/avm/file_formats/utf8_assert.rb', line 12

def assert_files(files)
  asserters = files.map { |file| new(file) }
  begin
    asserters.each(&:assert)
    yield
  ensure
    asserters.each(&:revert)
  end
end

Instance Method Details

#assertObject



26
27
28
29
30
# File 'lib/avm/file_formats/utf8_assert.rb', line 26

def assert
  return if original_utf8?

  convert_self(original_charset, UTF8_CHARSET)
end

#revertObject



32
33
34
35
36
# File 'lib/avm/file_formats/utf8_assert.rb', line 32

def revert
  return if original_utf8?

  convert_self(UTF8_CHARSET, original_charset)
end