Class: Sarif::Replacement
- Inherits:
-
Object
- Object
- Sarif::Replacement
- Defined in:
- lib/sarif/replacement.rb
Overview
The replacement of a single region of an artifact.
Instance Attribute Summary collapse
-
#deleted_region ⇒ Object
Returns the value of attribute deleted_region.
-
#inserted_content ⇒ Object
Returns the value of attribute inserted_content.
-
#properties ⇒ Object
Returns the value of attribute properties.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(deleted_region:, inserted_content: nil, properties: nil) ⇒ Replacement
constructor
A new instance of Replacement.
- #to_h ⇒ Object
- #to_json(pretty: false) ⇒ Object
Constructor Details
#initialize(deleted_region:, inserted_content: nil, properties: nil) ⇒ Replacement
Returns a new instance of Replacement.
8 9 10 11 12 |
# File 'lib/sarif/replacement.rb', line 8 def initialize(deleted_region:, inserted_content: nil, properties: nil) @deleted_region = deleted_region @inserted_content = inserted_content @properties = properties end |
Instance Attribute Details
#deleted_region ⇒ Object
Returns the value of attribute deleted_region.
6 7 8 |
# File 'lib/sarif/replacement.rb', line 6 def deleted_region @deleted_region end |
#inserted_content ⇒ Object
Returns the value of attribute inserted_content.
6 7 8 |
# File 'lib/sarif/replacement.rb', line 6 def inserted_content @inserted_content end |
#properties ⇒ Object
Returns the value of attribute properties.
6 7 8 |
# File 'lib/sarif/replacement.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/replacement.rb', line 26 def self.from_hash(h) return nil if h.nil? new( deleted_region: Region.from_hash(h["deletedRegion"]), inserted_content: ArtifactContent.from_hash(h["insertedContent"]), properties: h["properties"] ) end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
35 36 37 38 |
# File 'lib/sarif/replacement.rb', line 35 def ==(other) return false unless other.is_a?(Replacement) @deleted_region == other.deleted_region && @inserted_content == other.inserted_content && @properties == other.properties end |
#hash ⇒ Object
42 43 44 |
# File 'lib/sarif/replacement.rb', line 42 def hash [@deleted_region, @inserted_content, @properties].hash end |
#to_h ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/sarif/replacement.rb', line 14 def to_h h = {} h["deletedRegion"] = @deleted_region&.to_h h["insertedContent"] = @inserted_content&.to_h unless @inserted_content.nil? h["properties"] = @properties unless @properties.nil? h end |
#to_json(pretty: false) ⇒ Object
22 23 24 |
# File 'lib/sarif/replacement.rb', line 22 def to_json(pretty: false) pretty ? JSON.pretty_generate(to_h) : JSON.generate(to_h) end |