Sha256: f3617a6b880e88bed40dca4c8a924140808bcf06d200c22f600431408b868dad

Contents?: true

Size: 1003 Bytes

Versions: 20

Compression:

Stored size: 1003 Bytes

Contents

require 'ks'

module FormatParser
  class Archive
    include FormatParser::AttributesJSON

    class Entry < Ks.strict(:type, :size, :filename)
      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

20 entries across 20 versions & 1 rubygems

Version Path
format_parser-2.0.0 lib/archive.rb
format_parser-2.0.0.pre.4 lib/archive.rb
format_parser-2.0.0.pre.3 lib/archive.rb
format_parser-2.0.0.pre.2 lib/archive.rb
format_parser-2.0.0.pre lib/archive.rb
format_parser-1.7.0 lib/archive.rb
format_parser-1.6.0 lib/archive.rb
format_parser-1.5.0 lib/archive.rb
format_parser-1.4.2 lib/archive.rb
format_parser-1.4.1 lib/archive.rb
format_parser-1.4.0 lib/archive.rb
format_parser-1.3.0 lib/archive.rb
format_parser-1.2.1 lib/archive.rb
format_parser-1.2.0 lib/archive.rb
format_parser-1.1.0 lib/archive.rb
format_parser-1.0.0 lib/archive.rb
format_parser-0.29.1 lib/archive.rb
format_parser-0.29.0 lib/archive.rb
format_parser-0.28.0 lib/archive.rb
format_parser-0.27.0 lib/archive.rb