Class: Sarif::Fix
- Inherits:
-
Object
- Object
- Sarif::Fix
- Defined in:
- lib/sarif/fix.rb
Overview
A proposed fix for the problem represented by a result object. A fix specifies a set of artifacts to modify. For each artifact, it specifies a set of bytes to remove, and provides a set of new bytes to replace them.
Instance Attribute Summary collapse
-
#artifact_changes ⇒ Object
Returns the value of attribute artifact_changes.
-
#description ⇒ Object
Returns the value of attribute description.
-
#properties ⇒ Object
Returns the value of attribute properties.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(description: nil, artifact_changes:, properties: nil) ⇒ Fix
constructor
A new instance of Fix.
- #to_h ⇒ Object
- #to_json(pretty: false) ⇒ Object
Constructor Details
#initialize(description: nil, artifact_changes:, properties: nil) ⇒ Fix
Returns a new instance of Fix.
8 9 10 11 12 |
# File 'lib/sarif/fix.rb', line 8 def initialize(description: nil, artifact_changes:, properties: nil) @description = description @artifact_changes = artifact_changes @properties = properties end |
Instance Attribute Details
#artifact_changes ⇒ Object
Returns the value of attribute artifact_changes.
6 7 8 |
# File 'lib/sarif/fix.rb', line 6 def artifact_changes @artifact_changes end |
#description ⇒ Object
Returns the value of attribute description.
6 7 8 |
# File 'lib/sarif/fix.rb', line 6 def description @description end |
#properties ⇒ Object
Returns the value of attribute properties.
6 7 8 |
# File 'lib/sarif/fix.rb', line 6 def properties @properties end |
Class Method Details
.from_hash(h) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/sarif/fix.rb', line 26 def self.from_hash(h) return nil if h.nil? new( description: Message.from_hash(h["description"]), artifact_changes: h["artifactChanges"]&.map { |v| ArtifactChange.from_hash(v) }, properties: h["properties"] ) end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
35 36 37 38 |
# File 'lib/sarif/fix.rb', line 35 def ==(other) return false unless other.is_a?(Fix) @description == other.description && @artifact_changes == other.artifact_changes && @properties == other.properties end |
#hash ⇒ Object
42 43 44 |
# File 'lib/sarif/fix.rb', line 42 def hash [@description, @artifact_changes, @properties].hash end |
#to_h ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/sarif/fix.rb', line 14 def to_h h = {} h["description"] = @description&.to_h unless @description.nil? h["artifactChanges"] = @artifact_changes&.map(&:to_h) h["properties"] = @properties unless @properties.nil? h end |
#to_json(pretty: false) ⇒ Object
22 23 24 |
# File 'lib/sarif/fix.rb', line 22 def to_json(pretty: false) pretty ? JSON.pretty_generate(to_h) : JSON.generate(to_h) end |