Class: Uniword::Docx::StrippedPart

Inherits:
Object
  • Object
show all
Defined in:
lib/uniword/docx/stripped_part.rb

Overview

Reporting record for a part stripped at load time.

Created by Docx::PartLoader (in :strip policy mode) for every ZIP entry the JunkClassifier flagged. Stored on Package#stripped_parts for caller introspection.

Lightweight by design: no lutaml-model, no XML serialization. These are load-time metadata, never written to a package.

Examples:

part = StrippedPart.new(
  path: "[trash]/0000.dat",
  reason: "No content type declaration and no referencing " \
          "relationship",
)
part.path   # => "[trash]/0000.dat"
part.reason # => "No content type declaration..."

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path:, reason:) ⇒ StrippedPart

Returns a new instance of StrippedPart.

Parameters:

  • path (String)

    package-relative path of the stripped part

  • reason (String)

    why the part was stripped (human-readable, produced by JunkClassifier#reason)



28
29
30
31
# File 'lib/uniword/docx/stripped_part.rb', line 28

def initialize(path:, reason:)
  @path = path
  @reason = reason
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



23
24
25
# File 'lib/uniword/docx/stripped_part.rb', line 23

def path
  @path
end

#reasonObject (readonly)

Returns the value of attribute reason.



23
24
25
# File 'lib/uniword/docx/stripped_part.rb', line 23

def reason
  @reason
end

Instance Method Details

#==(other) ⇒ Boolean

Parameters:

  • other (Object)

Returns:

  • (Boolean)


51
52
53
# File 'lib/uniword/docx/stripped_part.rb', line 51

def ==(other)
  eql?(other)
end

#eql?(other) ⇒ Boolean

Value-object equality by path + reason.

Parameters:

  • other (Object)

Returns:

  • (Boolean)


37
38
39
40
# File 'lib/uniword/docx/stripped_part.rb', line 37

def eql?(other)
  other.is_a?(StrippedPart) && path == other.path &&
    reason == other.reason
end

#hashInteger

Combined with eql? for Hash/Set membership.

Returns:

  • (Integer)


45
46
47
# File 'lib/uniword/docx/stripped_part.rb', line 45

def hash
  [path, reason].hash
end