Class: Sarif::SpecialLocations
- Inherits:
-
Object
- Object
- Sarif::SpecialLocations
- Defined in:
- lib/sarif/special_locations.rb
Overview
Defines locations of special significance to SARIF consumers.
Instance Attribute Summary collapse
-
#display_base ⇒ Object
Returns the value of attribute display_base.
-
#properties ⇒ Object
Returns the value of attribute properties.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(display_base: nil, properties: nil) ⇒ SpecialLocations
constructor
A new instance of SpecialLocations.
- #to_h ⇒ Object
- #to_json(pretty: false) ⇒ Object
Constructor Details
#initialize(display_base: nil, properties: nil) ⇒ SpecialLocations
Returns a new instance of SpecialLocations.
8 9 10 11 |
# File 'lib/sarif/special_locations.rb', line 8 def initialize(display_base: nil, properties: nil) @display_base = display_base @properties = properties end |
Instance Attribute Details
#display_base ⇒ Object
Returns the value of attribute display_base.
6 7 8 |
# File 'lib/sarif/special_locations.rb', line 6 def display_base @display_base end |
#properties ⇒ Object
Returns the value of attribute properties.
6 7 8 |
# File 'lib/sarif/special_locations.rb', line 6 def properties @properties end |
Class Method Details
.from_hash(h) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/sarif/special_locations.rb', line 24 def self.from_hash(h) return nil if h.nil? new( display_base: ArtifactLocation.from_hash(h["displayBase"]), properties: h["properties"] ) end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
32 33 34 35 |
# File 'lib/sarif/special_locations.rb', line 32 def ==(other) return false unless other.is_a?(SpecialLocations) @display_base == other.display_base && @properties == other.properties end |
#hash ⇒ Object
39 40 41 |
# File 'lib/sarif/special_locations.rb', line 39 def hash [@display_base, @properties].hash end |
#to_h ⇒ Object
13 14 15 16 17 18 |
# File 'lib/sarif/special_locations.rb', line 13 def to_h h = {} h["displayBase"] = @display_base&.to_h unless @display_base.nil? h["properties"] = @properties unless @properties.nil? h end |
#to_json(pretty: false) ⇒ Object
20 21 22 |
# File 'lib/sarif/special_locations.rb', line 20 def to_json(pretty: false) pretty ? JSON.pretty_generate(to_h) : JSON.generate(to_h) end |