class BerkeleyLibrary::Util::ODS::XML::Manifest::FileEntry

Attributes

full_path[R]
manifest[R]
media_type[R]

Public Class Methods

new(full_path, media_type = nil, manifest:) click to toggle source
# File lib/berkeley_library/util/ods/xml/manifest/file_entry.rb, line 14
def initialize(full_path, media_type = nil, manifest:)
  super(:manifest, 'file-entry', doc: manifest.doc)

  @full_path = full_path
  @media_type = media_type || media_type_for(full_path)
  @manifest = manifest

  set_default_attributes!
end

Private Instance Methods

media_type_for(path) click to toggle source
# File lib/berkeley_library/util/ods/xml/manifest/file_entry.rb, line 26
def media_type_for(path)
  return 'application/vnd.oasis.opendocument.spreadsheet' if path == '/'
  return 'text/xml' if path.end_with?('.xml')

  raise ArgumentError, "Can't determine media type for path: #{path.inspect}"
end
set_default_attributes!() click to toggle source
# File lib/berkeley_library/util/ods/xml/manifest/file_entry.rb, line 33
def set_default_attributes!
  set_attribute('full-path', full_path)
  set_attribute('media-type', media_type)
end