Class: Avm::FileFormats::Base

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

Instance Method Summary collapse

Instance Method Details

#apply(files) ⇒ Object



13
14
15
16
17
# File 'lib/avm/file_formats/base.rb', line 13

def apply(files)
  old_content = Hash[files.map { |f| [f, File.read(f)] }]
  ::Avm::FileFormats::Utf8Assert.assert_files(files) { internal_apply(files) }
  files.map { |f| build_file_result(f, old_content[f]) }
end

#file_resource_name(path) ⇒ Avm::FileFormats::FileWith

Parameters:

  • path (Pathname)

Returns:

  • (Avm::FileFormats::FileWith)


21
22
23
# File 'lib/avm/file_formats/base.rb', line 21

def file_resource_name(path)
  path.to_pathname.to_path
end

#match?(file) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/avm/file_formats/base.rb', line 29

def match?(file)
  match_by_filename?(file) || match_by_type?(file)
end

#nameObject



25
26
27
# File 'lib/avm/file_formats/base.rb', line 25

def name
  self.class.name.demodulize
end

#valid_basenamesObject



33
34
35
# File 'lib/avm/file_formats/base.rb', line 33

def valid_basenames
  constant_or_array('VALID_BASENAMES')
end

#valid_typesObject



37
38
39
# File 'lib/avm/file_formats/base.rb', line 37

def valid_types
  constant_or_array('VALID_TYPES')
end