class Epuber::Compiler::FileTypes::AbstractFile
Attributes
@return [Epuber::Compiler::CompilationContext] non-nil value only during process() method
@return [String] relative destination path
@return [String] final absolute destination path calculated by FileResolver
@return [Symbol] group of this file (:text, :image, :font, …), see
Epuber::Compiler::FileFinder::GROUP_EXTENSIONS
@return [Symbol] type of path, one of :spine, :manifest, :package
@return [String] final relative destination path from root of the package calculated by FileResolver
@return [Set<Symbol>] list of properties
Public Class Methods
Source
# File lib/epuber/compiler/file_types/abstract_file.rb, line 54 def self.file_copy!(source_path, dest_path) FileUtils.mkdir_p(File.dirname(dest_path)) FileUtils.cp(source_path, dest_path) end
@param [String] source_path @param [String] dest_path
@return nil
Source
# File lib/epuber/compiler/file_types/abstract_file.rb, line 76 def self.write_to_file(content, to_path) return unless write_to_file?(content, to_path) write_to_file!(content, to_path) end
@param [String | to_s] content anything, that can be converted to string and should be written to file @param [String] to_path destination path
@return nil
Source
# File lib/epuber/compiler/file_types/abstract_file.rb, line 87 def self.write_to_file!(content, to_path) FileUtils.mkdir_p(File.dirname(to_path)) File.write(to_path, content) end
@param [String | to_s] content anything, that can be converted to string and should be written to file @param [String] to_path destination path
@return nil
Source
# File lib/epuber/compiler/file_types/abstract_file.rb, line 65 def self.write_to_file?(content, to_path) return true unless File.exist?(to_path) File.read(to_path) != content.to_s end
@param [String | to_s] content anything, that can be converted to string and should be written to file @param [String] to_path destination path
@return nil
Public Instance Methods
Source
# File lib/epuber/compiler/file_types/abstract_file.rb, line 42 def ==(other) self.class == other.class && final_destination_path == other.final_destination_path end
Source
# File lib/epuber/compiler/file_types/abstract_file.rb, line 22 def properties @properties ||= Set.new end
@return [Set<Symbol>] list of properties