Sha256: 98df418f42431463d0d99893b164458c5c961cc96de96c72f92f8f244c5c22b5

Contents?: true

Size: 1010 Bytes

Versions: 15

Compression:

Stored size: 1010 Bytes

Contents

module FormatParser
  class Archive
    include FormatParser::AttributesJSON

    class Entry < Struct.new(:type, :size, :filename, keyword_init: true)
      def to_json(*a)
        to_h.to_json(*a)
      end
    end

    # Lots of Office and LibreOffice documents are in fact packaged into
    # ZIPs, as are .epub files. We make `nature` customisable for this occasion
    attr_accessor :nature

    # What filetype was recognized? Will contain a non-ambiguous symbol
    # referring to the file format. The symbol can be used as a filename
    # extension safely
    attr_accessor :format

    # Array of Entry structs
    attr_accessor :entries

    # If a parser wants to provide any extra information to the caller
    # it can be placed here
    attr_accessor :intrinsics

    # The MIME type of the archive
    attr_accessor :content_type

    # Only permits assignments via defined accessors
    def initialize(**attributes)
      attributes.map { |(k, v)| public_send("#{k}=", v) }
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
format_parser-2.10.0 lib/archive.rb
format_parser-2.9.0 lib/archive.rb
format_parser-2.8.0 lib/archive.rb
format_parser-2.7.2 lib/archive.rb
format_parser-2.7.1 lib/archive.rb
format_parser-2.7.0 lib/archive.rb
format_parser-2.6.0 lib/archive.rb
format_parser-2.5.0 lib/archive.rb
format_parser-2.4.5 lib/archive.rb
format_parser-2.4.4 lib/archive.rb
format_parser-2.4.3 lib/archive.rb
format_parser-2.3.0 lib/archive.rb
format_parser-2.2.1 lib/archive.rb
format_parser-2.2.0 lib/archive.rb
format_parser-2.1.0 lib/archive.rb