Class: Ocran::ZipWriter::Entry

Inherits:
Struct
  • Object
show all
Defined in:
lib/ocran/zip_writer.rb

Overview

An archive member to add. name is the archive-relative path (with forward slashes, no leading slash); a name ending in "/" is a directory entry with no content. source is a path to read the content from, data is the content itself; exactly one of them is given for a file entry.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#dataObject

Returns the value of attribute data

Returns:

  • (Object)

    the current value of data



82
83
84
# File 'lib/ocran/zip_writer.rb', line 82

def data
  @data
end

#modeObject

Returns the value of attribute mode

Returns:

  • (Object)

    the current value of mode



82
83
84
# File 'lib/ocran/zip_writer.rb', line 82

def mode
  @mode
end

#mtimeObject

Returns the value of attribute mtime

Returns:

  • (Object)

    the current value of mtime



82
83
84
# File 'lib/ocran/zip_writer.rb', line 82

def mtime
  @mtime
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



82
83
84
# File 'lib/ocran/zip_writer.rb', line 82

def name
  @name
end

#sourceObject

Returns the value of attribute source

Returns:

  • (Object)

    the current value of source



82
83
84
# File 'lib/ocran/zip_writer.rb', line 82

def source
  @source
end

Instance Method Details

#contentObject



85
86
87
88
89
# File 'lib/ocran/zip_writer.rb', line 85

def content
  return "".b if directory?

  (data || File.binread(source)).b
end

#directory?Boolean

Returns:

  • (Boolean)


83
# File 'lib/ocran/zip_writer.rb', line 83

def directory? = name.end_with?("/")