Class: Sarif::ArtifactChange
- Inherits:
-
Object
- Object
- Sarif::ArtifactChange
- Defined in:
- lib/sarif/artifact_change.rb
Overview
A change to a single artifact.
Instance Attribute Summary collapse
-
#artifact_location ⇒ Object
Returns the value of attribute artifact_location.
-
#properties ⇒ Object
Returns the value of attribute properties.
-
#replacements ⇒ Object
Returns the value of attribute replacements.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(artifact_location:, replacements:, properties: nil) ⇒ ArtifactChange
constructor
A new instance of ArtifactChange.
- #to_h ⇒ Object
- #to_json(pretty: false) ⇒ Object
Constructor Details
#initialize(artifact_location:, replacements:, properties: nil) ⇒ ArtifactChange
Returns a new instance of ArtifactChange.
8 9 10 11 12 |
# File 'lib/sarif/artifact_change.rb', line 8 def initialize(artifact_location:, replacements:, properties: nil) @artifact_location = artifact_location @replacements = replacements @properties = properties end |
Instance Attribute Details
#artifact_location ⇒ Object
Returns the value of attribute artifact_location.
6 7 8 |
# File 'lib/sarif/artifact_change.rb', line 6 def artifact_location @artifact_location end |
#properties ⇒ Object
Returns the value of attribute properties.
6 7 8 |
# File 'lib/sarif/artifact_change.rb', line 6 def properties @properties end |
#replacements ⇒ Object
Returns the value of attribute replacements.
6 7 8 |
# File 'lib/sarif/artifact_change.rb', line 6 def replacements @replacements end |
Class Method Details
.from_hash(h) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/sarif/artifact_change.rb', line 26 def self.from_hash(h) return nil if h.nil? new( artifact_location: ArtifactLocation.from_hash(h["artifactLocation"]), replacements: h["replacements"]&.map { |v| Replacement.from_hash(v) }, properties: h["properties"] ) end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
35 36 37 38 |
# File 'lib/sarif/artifact_change.rb', line 35 def ==(other) return false unless other.is_a?(ArtifactChange) @artifact_location == other.artifact_location && @replacements == other.replacements && @properties == other.properties end |
#hash ⇒ Object
42 43 44 |
# File 'lib/sarif/artifact_change.rb', line 42 def hash [@artifact_location, @replacements, @properties].hash end |
#to_h ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/sarif/artifact_change.rb', line 14 def to_h h = {} h["artifactLocation"] = @artifact_location&.to_h h["replacements"] = @replacements&.map(&:to_h) h["properties"] = @properties unless @properties.nil? h end |
#to_json(pretty: false) ⇒ Object
22 23 24 |
# File 'lib/sarif/artifact_change.rb', line 22 def to_json(pretty: false) pretty ? JSON.pretty_generate(to_h) : JSON.generate(to_h) end |