Class: EPUB::OCF::PhysicalContainer

Inherits:
Object
  • Object
show all
Defined in:
lib/epub/maker/ocf/physical_container.rb,
lib/epub/maker/ocf/physical_container/rubyzip.rb,
lib/epub/maker/ocf/physical_container/zipruby.rb,
lib/epub/maker/ocf/physical_container/archive_zip.rb

Direct Known Subclasses

ArchiveZip, Rubyzip, Zipruby

Defined Under Namespace

Classes: ArchiveZip, Rubyzip, Zipruby

Constant Summary collapse

@@mtime =
nil

Class Method Summary collapse

Class Method Details

.mtimeObject



19
20
21
# File 'lib/epub/maker/ocf/physical_container.rb', line 19

def mtime
  @@mtime
end

.mtime=(time) ⇒ Time

Sets mtime, which is used when setting mtime of file in EPUB(ZIP) archive. Currently supported for only ArchiveZip adapter

Examples:

EPUB::OCF::PhysicalCotainer.adapter = :ArchiveZip
EPUB::OCF::PhysicalCotainer.mtime = Time.new(2020, 1, 1)

Parameters:

  • time (Time)

    mtime to set

Returns:

  • (Time)


32
33
34
# File 'lib/epub/maker/ocf/physical_container.rb', line 32

def mtime=(time)
  @@mtime = time
end

.save(container_path, path_name, content) ⇒ Object



42
43
44
45
# File 'lib/epub/maker/ocf/physical_container.rb', line 42

def save(container_path, path_name, content)
  warn "EPUB::OCF::PhysicalContainer.#{__method__} is deprecated. Use .write instead"
  write(container_path, path_name, content, mtime: mtime)
end

.write(container_path, path_name, content) ⇒ Object



36
37
38
39
40
# File 'lib/epub/maker/ocf/physical_container.rb', line 36

def write(container_path, path_name, content)
  open(container_path) {|container|
    container.write(path_name, content, mtime: mtime)
  }
end